- Home /
Connect Client to Server from a Different project
Hello,
I have the follwing problem: I initialized a server on unity project 1 and connected a client from the same project. But now I want to connect a client from unity project 2, but when the this client tries to connect the server shuts down with the following error message: New incoming connection but not a server Afterwards the server shuts down. (If I try to connect the external client without having an exisiting client already connected it just doesn't connect without any error messages or shut downs.)
Server Code:
private const string typeName = "ControllerConnection";
private const string gameName = "Zodiac";
void Awake()
{
StartServer ();
}
private void StartServer()
{
Network.InitializeServer (4, 25000, !Network.HavePublicAddress ());
MasterServer.RegisterHost (typeName, gameName);
}
void OnServerInitialized()
{
Debug.Log ("Server Initialized");
}
Client Code:
private const string typeName = "ControllerConnection";
private HostData[] hostList;
private int movement = 0;
void Start () {
StartCoroutine (waitForIt ());
}
private void RefreshHostList()
{
MasterServer.RequestHostList (typeName);
Debug.Log ("1. Requested Host List");
}
void OnMasterServerEvent(MasterServerEvent msEvent)
{
if (msEvent == MasterServerEvent.HostListReceived)
{
Debug.Log("2. Startet to Join Server");
hostList = MasterServer.PollHostList ();
JoinServer(hostList[0]);
}
}
private void JoinServer(HostData hostData)
{
Debug.Log ("3. Attempt to Connect");
Network.Connect (hostData);
}
IEnumerator waitForIt()
{
yield return new WaitForSeconds (5);
RefreshHostList();
}
void OnConnectedToServer()
{
Debug.Log ("4. Connected");
}
I hope someone can help me out!! Thanks!
Your answer
Follow this Question
Related Questions
Creating a multiplayer game. 1 Answer
How to watch in client applications what it is happening in the server one? 0 Answers
Networking 0 Answers
Is there a way to notify to the app once client has connected to server? 2 Answers
Seperate server - client 2 Answers