Exemplo n.º 1
0
        private void OnAccept(Socket socket)
        {
            IPEndPoint endPoint = socket.RemoteEndPoint as IPEndPoint;

            if (endPoint != null)
            {
                Debug.Log("Client connected on ip " + endPoint.Address.ToString() + " and port " + endPoint.Port);
            }
            else
            {
                Debug.Log("Client connected");
            }

            if (m_TcpClients.Count < 3)
            {
                TcpClientCoroutine tcpClient = new TcpClientCoroutine(this, socket);
                int clientIndex = m_TcpClients.Count;
                m_TcpClients.Add(tcpClient);
                tcpClient.OnDisconnected += () => DisconnectedClient(clientIndex);
                tcpClient.OnRecieved     += (bytes) => ReceiveClientMessage(bytes, clientIndex);
            }
        }
 private void Awake()
 {
     m_TcpClient = new TcpClientCoroutine(this);
 }