Hello and thanks for your time in advance, I have a simple client/server architecture which just doesn't work. The problem: If a client connects (testing from localhost) the server creates 2 connections for the client and the NetworkServer.connections.count raises by 2, which makes it impossible to work correctly. What happens: everything works fine on the clientside (I think), it's only sending the "connecting" and "connected" messages once, but the server opens two connections and I don't get why... I left some unimportant code out because it would be too much to read I guess. I would be so thankful if you guys could help me out. My script so far: Server Spoiler: Servercode Code (CSharp): public class ServerBehaviour : MonoBehaviour { NetworkClient myClient; bool running=false; int clientCount=0; // Message IDs public static short spawnMobMsgID = 10000; public static short pingID = 10001; public void startServer(){ if (!running) { NetworkServer.Listen (1337); NetworkServer.RegisterHandler (spawnMobMsgID, onSpawnMobMessage); NetworkServer.RegisterHandler (pingID, onPing); running = true; Debug.Log ("server running"); } } public void stopServer(){ if (running) { NetworkServer.Shutdown (); running = false; Debug.Log ("server stopped"); } } void Update () { int connectedClients = NetworkServer.connections.Count; if (connectedClients > clientCount) { Debug.Log ("connection id " + NetworkServer.connections [connectedClients - 1].connectionId + " connected"); clientCount++; } } } and the client... Spoiler: Clientcode Code (CSharp): public class Networking : MonoBehaviour { NetworkClient myClient; bool connected=false; //messageIDs public static short spawnMobMsgId = 10000; public static short pingID = 10001; // Use this for initialization void Start () { } public void connect(){ if (!connected) { connected = true; myClient = new NetworkClient (); myClient.RegisterHandler (MsgType.Connect, OnConnected); myClient.RegisterHandler (pingID, onPing); myClient.Connect ("127.0.0.1", 1337); Debug.Log ("connecting"); } } void OnConnected(NetworkMessage netMsg) { Debug.Log("Connected to server"); Debug.Log ("connection id" + myClient.connection.connectionId); } // Update is called once per frame void Update () { } }
having same issue and i'm using ServerSimple. do i really need to * all my indexes by 2? or is there just one dummy connection in the 0 index and i need to +1? Ah the things we do to make unity function normally.