Пример #1
0
        public void Send(TcpClient client, NetworkMessage message)
        {
            NetworkStream stream = client.GetStream();

            formatter.Serialize(stream, message);

            Console.WriteLine("Sent message to client {0}: {1}", client.Client.RemoteEndPoint.ToString(), message.ToString());
        }
Пример #2
0
        public void Broadcast(NetworkMessage message)
        {
            foreach(TcpClient client in clients)
            {
                Send(client, message);
            }

            Console.WriteLine("Broadcasted message to all clients: {0}", message.ToString());
        }
Пример #3
0
 public void Send(NetworkMessage message)
 {
     formatter.Serialize(stream, message);
     Debug.Log("Sent message to server: " + message.ToString());
 }