Exemplo n.º 1
0
        private byte[] Serialize(ClientMessage message)
        {
            MemoryStream stream = new MemoryStream();

            Serializer.Serialize(stream, message);
            return(stream.ToArray());
        }
Exemplo n.º 2
0
 public Client(string _playerId, string _authtoken)
 {
     playerId      = _playerId;
     authtoken     = _authtoken;
     host          = Config.udpHost;
     port          = Config.udpPort;
     clientMessage = CreateClientMessage();
     Start();
 }
Exemplo n.º 3
0
        private void dataReady(IAsyncResult ar)
        {
            byte[]        bytes   = udpClient.EndReceive(ar, ref udp_ep);
            ClientMessage message = Deserialize(bytes);

            foreach (Entity entity in message.entity)
            {
                entityQueue.Enqueue(entity);
            }
            receiveData();
        }
Exemplo n.º 4
0
        public ClientMessage CreateClientMessage()
        {
            Player player = new Player();

            player.id        = playerId;
            player.authtoken = authtoken;
            ClientMessage clientMessage = new ClientMessage();

            clientMessage.player = player;
            return(clientMessage);
        }