예제 #1
0
        private void ResponseConnectionAttemptRequest(string key, IPEndPoint ipe)
        {
            SignalingServerMessage ssm = new SignalingServerMessage(SignalingMethod.ConnectionAttemptResponse);

            byte[] addressByte = ipe.Address.GetAddressBytes();
            byte[] ip          = new byte[3 + addressByte.Length];
            if (addressByte.Length > 4)
            {
                ip[0] = 0x2;
            }
            else
            {
                ip[0] = 0x1;
            }
            ushort port = (ushort)ipe.Port;

            ip[2] = (byte)(port & 0xff);
            ip[1] = (byte)((port >> 8) & 0xff);
            Array.Copy(addressByte, 0, ip, 3, addressByte.Length);
            ssm.WriteBytes(SignalingAttribute.PeerAddress, ip);
            lock (_lock)
            {
                senderTable[key].Send(ssm.WriteRequest());
            }
        }
예제 #2
0
        private void ResponseCreateRoom(bool success)
        {
            SignalingServerMessage ssm = new SignalingServerMessage(SignalingMethod.CreateRoomResponse);

            if (success)
            {
                ssm.WriteEmpty(SignalingAttribute.Success);
            }
            else
            {
                ssm.WriteEmpty(SignalingAttribute.Failed);
            }
            sender.Send(ssm.WriteRequest());
        }
예제 #3
0
        private void ResponseGetRoomList(string tag)
        {
            SignalingServerMessage ssm = new SignalingServerMessage(SignalingMethod.GetRoomListResponse);
            //
            List <Room> sameTag;

            lock (_lock)
            {
                sameTag = room.FindAll(x => x.Tag == tag);
            }
            //Console.WriteLine("Result Room Tag: {0}, total: {1}", tag, sameTag.Count);
            for (int i = 0; i < sameTag.Count; i++)
            {
                Console.WriteLine("Find: " + sameTag[i].ToString());
                byte[] addressByte = sameTag[i].IP.Address.GetAddressBytes();
                byte[] ip          = new byte[3 + addressByte.Length];
                if (addressByte.Length > 4)
                {
                    ip[0] = 0x2;
                }
                else
                {
                    ip[0] = 0x1;
                }
                ushort port = (ushort)sameTag[i].IP.Port;
                ip[2] = (byte)(port & 0xff);
                ip[1] = (byte)((port >> 8) & 0xff);
                Array.Copy(addressByte, 0, ip, 3, addressByte.Length);
                ssm.WriteString(SignalingAttribute.RoomName, sameTag[i].Name);
                ssm.WriteString(SignalingAttribute.RoomDescription, sameTag[i].Description);
                ssm.WriteBytes(SignalingAttribute.RoomAddress, ip);
                Console.WriteLine("Key: " + sameTag[i].Key);
            }
            Console.WriteLine("Result Room Tag: {0}, total: {1}", tag, sameTag.Count);
            sender.Send(ssm.WriteRequest());
        }