public static async UniTask JoinRoom(MatchingLANPacket info)
 {
     foreach (var ip in info.PeerIPEndPoints)
     {
         await UniP2PManager.ConnectPeerAsync(IPEndPointParser.Parse(ip));
     }
 }
Beispiel #2
0
 public static async UniTask CreateRoom(string roomname, int maxmember)
 {
     CurrentInfo = new MatchingLANPacket
     {
         Event     = LANBroadcastEvent.Response,
         GameKey   = Application.productName,
         RoomName  = roomname,
         Peerid    = UniP2PManager.MyPeerID,
         MaxMember = maxmember,
     };
     await Init();
 }
        public static async UniTask RequestListRoom()
        {
            CurrentInfo = new MatchingLANPacket
            {
                Event = LANBroadcastEvent.Request,
            };
            var buffer = MessagePackSerializer.Serialize(CurrentInfo);

            if (JoinUdpClient != null)
            {
                JoinUdpClient.Close();
                JoinUdpClient = null;
            }

            JoinUdpClient = new UdpClient(UniP2PManager.AdvancedSettings.LANMatchingBroadcastPort);

            await SendBroadCastAsync(MessagePackSerializer.Serialize(CurrentInfo));
            await ReceiveStartAsync();
        }