Exemple #1
0
 public ChannelControlMessage()
 {
     Header = new RtpHeader()
     {
         PayloadType = NanoPayloadType.ChannelControl
     };
 }
 public ControlHandshake()
 {
     Header = new RtpHeader()
     {
         PayloadType = NanoPayloadType.ControlHandshake
     };
 }
 public UdpHandshake()
 {
     Header = new RtpHeader()
     {
         PayloadType = NanoPayloadType.UDPHandshake
     };
 }
Exemple #4
0
 public ChannelControlMessage(ChannelControlType type)
 {
     Header = new RtpHeader()
     {
         PayloadType = NanoPayloadType.ChannelControl
     };
     Type = type;
 }
 public UdpHandshake(ControlHandshakeType type)
 {
     Header = new RtpHeader()
     {
         PayloadType = NanoPayloadType.UDPHandshake
     };
     Type = type;
 }
 public ControlHandshake(ControlHandshakeType type, ushort connectionId)
 {
     Header = new RtpHeader()
     {
         PayloadType = NanoPayloadType.ControlHandshake
     };
     Type         = type;
     ConnectionId = connectionId;
 }
 public StreamerMessage()
 {
     Header = new RtpHeader()
     {
         PayloadType = NanoPayloadType.Streamer
     };
     StreamerSize   = 0;
     StreamerHeader = new StreamerHeader();
 }
 public StreamerMessageWithHeader(ControlOpCode opCode)
 {
     Header = new RtpHeader()
     {
         PayloadType = NanoPayloadType.Streamer
     };
     StreamerHeader = new StreamerHeader()
     {
         PacketType = 0
     };
     ControlHeader = new StreamerControlHeader(opCode);
 }
 public StreamerMessage(uint StreamerType)
 {
     Header = new RtpHeader()
     {
         PayloadType = NanoPayloadType.Streamer
     };
     StreamerSize   = 0;
     StreamerHeader = new StreamerHeader()
     {
         PacketType = StreamerType
     };
 }
Exemple #10
0
        public static INanoPacket ParsePacket(byte[] data, NanoChannelContext context)
        {
            EndianReader packetReader = new EndianReader(data);
            RtpHeader    header       = new RtpHeader();

            header.Deserialize(packetReader);
            NanoPayloadType payloadType = header.PayloadType;

            // It might be NanoChannel.Unknown at this point, if ChannelCreate
            // packet was not processed yet
            // It gets processed at the end of the function
            NanoChannel channel = context.GetChannel(header.ChannelId);

            INanoPacket packet        = null;
            long        payloadOffset = packetReader.Position;

            switch (payloadType)
            {
            // FIXME: Create from Attribute is broken
            case NanoPayloadType.UDPHandshake:
                packet = new UdpHandshake();
                break;

            case NanoPayloadType.ControlHandshake:
                packet = new ControlHandshake();
                break;

            case NanoPayloadType.ChannelControl:
                // Read type to pinpoint exact payload
                ChannelControlType cct =
                    (ChannelControlType)packetReader.ReadUInt32LE();
                packet = CreateFromChannelControlType(cct);
                break;

            case NanoPayloadType.Streamer:
                packet = CreateFromStreamerHeader(packetReader, channel);
                break;

            default:
                throw new NanoPackingException(
                          $"Unknown packet type received: {payloadType}");
            }

            if (packet == null)
            {
                throw new NanoPackingException("Failed to find matching body for packet");
            }

            packetReader.Seek(payloadOffset, SeekOrigin.Begin);
            packet.Deserialize(packetReader);
            packet.Header = header;

            if (packet as ChannelCreate != null)
            {
                string channelName = ((ChannelCreate)packet).Name;
                channel = NanoChannelClass.GetIdByClassName(channelName);
            }

            if (channel == NanoChannel.Unknown)
            {
                throw new NanoPackingException("ParsePacket: INanoPacket.Channel is UNKNOWN");
            }

            packet.Channel = channel;
            return(packet);
        }