Exemple #1
0
        public static PacketType GetPacket(byte[] packetData, int byteCount, out object packet)
        {
            PacketType type = (PacketType)packetData[0];

            switch (type)
            {
            case PacketType.ConnectionRequest:
                packet = new ConnectionRequestPacket()
                {
                    options = packetData[1]
                };
                break;

            case PacketType.ClientDefinition:
                if (BitConverter.IsLittleEndian)
                {
                    Array.Reverse(packetData, 1, 2);
                    Array.Reverse(packetData, 3, 2);
                }
                packet = new ClientDefinitionPacket()
                {
                    width = BitConverter.ToUInt16(packetData, 1), height = BitConverter.ToUInt16(packetData, 3)
                };
                break;

            case PacketType.TargetDefinition:
                if (BitConverter.IsLittleEndian)
                {
                    Array.Reverse(packetData, 1, 2);
                    Array.Reverse(packetData, 3, 2);
                }
                packet = new TargetDefinitionPacket()
                {
                    width = BitConverter.ToUInt16(packetData, 1), height = BitConverter.ToUInt16(packetData, 3)
                };
                break;

            case PacketType.StreamRequest:
                packet = new StreamRequestPacket()
                {
                    options = packetData[1]
                };
                break;

            case PacketType.Stream:
                //TODO: Do the packet shit
                packet = new StreamPacket()
                {
                };
                break;

            default:
                type   = PacketType.Unknown;
                packet = null;
                break;
            }

            return(type);
        }
Exemple #2
0
 public bool Send(StreamPacket packet)
 {
     return(false);
 }