Пример #1
0
        public static BaseMessage Receive(Socket socket)
        {
            byte[] byteSize = new byte[4];
            socket.Receive(byteSize);
            int size = MessageSerialization.GetMessageSize(byteSize);

            byte[] payload = new byte[size];
            socket.Receive(payload);
            BaseMessage message = MessageSerialization.Deserialze(payload);

            return(message);
        }
Пример #2
0
 public static void Send(Socket socket, BaseMessage msg)
 {
     byte[] serialized = MessageSerialization.Serialize(msg);
     socket.Send(serialized.Length.ToBytes());
     socket.Send(serialized);
 }