Beispiel #1
0
        public void Awake()
        {
            instance = this;

            if (serverIp == null)
            { // Server: start listening for connections
                listener = new TcpListener(IPAddress.Any, port);
                listener.Start();
                listener.BeginAcceptTcpClient(OnServerConnect, null);
            }
            else
            { // Client: try connecting to the server
                TcpClient          client          = new TcpClient();
                TcpConnectedClient connectedClient = new TcpConnectedClient(client);
                clientList.Add(connectedClient);
                client.BeginConnect(serverIp, port, (ar) => connectedClient.EndConnect(ar), null);
            }
        }
Beispiel #2
0
 public void OnDisconnect(TcpConnectedClient client)
 {
     clientList.Remove(client);
 }