コード例 #1
0
ファイル: UdpConnection.cs プロジェクト: TheProxor/PGN-Core
        public void Recieve(byte[] bytes)
        {
            NetData message = NetData.RecoverBytes(bytes);

            if (message != null && message.number > lastMessageNumber)
            {
                if (ServerHandler.clients.Contains(message.sender.ID))
                {
                    if ((ServerHandler.clients[message.sender.ID] as NetUser).udpConnection == null)
                    {
                        NetUser.OnUserConnectedUDP(message.sender);
                    }
                    netUser = ServerHandler.clients[message.sender.ID] as NetUser;
                    netUser.udpConnection = this;
                }
                else
                {
                    netUser = new NetUser(message.sender);
                    netUser.udpConnection = this;
                    ServerHandler.AddConnection(netUser);
                    NetUser.OnUserConnectedUDP(message.sender);
                }
                NetUser.OnUdpMessageHandleCallback(bytes, message, netUser);
                lastMessageNumber = message.number;
            }
        }