示例#1
0
        public void Register(uint userId)
        {
            Console.WriteLine("Register with serving node");

            var sendBuffer = _protocolSwitch.SendBuffer();

            //packet type (byte)
            sendBuffer[0] = (byte)RopuPacketType.Registration;
            // User ID (uint32)
            sendBuffer.WriteUint(userId, 1);

            _protocolSwitch.Send(5);
        }
示例#2
0
        void SendMediaPacket(ushort groupId, ushort sequenceNumber, uint userId, short[] audio)
        {
            var buffer = _protocolSwitch.SendBuffer();

            // Packet Type 12 (byte)
            buffer[0] = (byte)RopuPacketType.MediaPacketGroupCallClient;
            // Group Id (uint16)
            buffer.WriteUshort(groupId, 1);
            // Sequence Number (uint16)
            buffer.WriteUshort(sequenceNumber, 3);
            // User ID (uint32)
            buffer.WriteUint(userId, 5);
            // Key ID (uint16) - 0 means no encryption
            buffer.WriteUshort(0, 9);
            // Payload
            int ammountEncoded = _audioCodec.Encode(audio, buffer.AsSpan(11));

            _protocolSwitch.Send(11 + ammountEncoded);
        }