Exemplo n.º 1
0
        void OnCommandReceived(UdpBitStream buffer)
        {
            if (ParseHeader(ref buffer))
            {
                stats.CommandsReceived += 1;

                buffer.Ptr = UdpHeader.GetSize(socket);
                UdpCommandType cmd = (UdpCommandType)buffer.ReadByte(8);

                switch (cmd)
                {
                case UdpCommandType.Connect: OnCommandConnect(buffer); break;

                case UdpCommandType.Accepted: OnCommandAccepted(buffer); break;

                case UdpCommandType.Refused: OnCommandRefused(buffer); break;

                case UdpCommandType.Disconnected: OnCommandDisconnected(buffer); break;

                case UdpCommandType.Ping: OnCommandPing(buffer); break;

                default: ConnectionError(UdpConnectionError.IncorrectCommand); break;
                }
            }
        }
Exemplo n.º 2
0
        void RecvUnconnectedPacket(UdpBitStream buff, UdpEndPoint ep)
        {
            buff.Ptr = UdpHeader.GetSize(this);

            if (buff.ReadByte(8) == (byte)UdpCommandType.Connect)
            {
                if (Config.AllowIncommingConnections && ((connLookup.Count + pendingConnections.Count) < Config.ConnectionLimit || Config.ConnectionLimit == -1))
                {
                    if (Config.AutoAcceptIncommingConnections)
                    {
                        AcceptConnection(ep);
                    }
                    else
                    {
                        if (pendingConnections.Add(ep))
                        {
                            Raise(UdpEvent.PUBLIC_CONNECT_REQUEST, ep);
                        }
                    }
                }
                else
                {
                    SendRefusedCommand(ep);
                }
            }
            else
            {
                UdpLog.Debug("received invalid header byte in unconnected packet from {0}", ep.ToString());
            }
        }
Exemplo n.º 3
0
 public static Color32 ReadColor32RGB(ref UdpBitStream stream)
 {
     return(new Color32(stream.ReadByte(8), stream.ReadByte(8), stream.ReadByte(8), 0xFF));
 }
Exemplo n.º 4
0
        void OnCommandReceived(UdpBitStream buffer)
        {
            if (ParseHeader(ref buffer)) {
                stats.CommandsReceived += 1;

                buffer.Ptr = UdpHeader.GetSize(socket);
                UdpCommandType cmd = (UdpCommandType) buffer.ReadByte(8);

                switch (cmd) {
                    case UdpCommandType.Connect: OnCommandConnect(buffer); break;
                    case UdpCommandType.Accepted: OnCommandAccepted(buffer); break;
                    case UdpCommandType.Refused: OnCommandRefused(buffer); break;
                    case UdpCommandType.Disconnected: OnCommandDisconnected(buffer); break;
                    case UdpCommandType.Ping: OnCommandPing(buffer); break;
                    default: ConnectionError(UdpConnectionError.IncorrectCommand); break;
                }
            }
        }
Exemplo n.º 5
0
 public static Color32 ReadColor32RGBA(ref UdpBitStream stream)
 {
     return new Color32(stream.ReadByte(8), stream.ReadByte(8), stream.ReadByte(8), stream.ReadByte(8));
 }