Ejemplo n.º 1
0
        private void Awake()
        {
            //Если в прошлом бою уже был создан UdpClient
            udpClientWrapper?.Stop();

            BattleRoyaleClientMatchModel matchData = MyMatchDataStorage.Instance.GetMatchModel();
            int         matchId          = matchData.MatchId;
            int         gameServerPort   = matchData.GameServerPort;
            string      gameServerIp     = matchData.GameServerIp;
            IPEndPoint  serverIpEndPoint = new IPEndPoint(IPAddress.Parse(gameServerIp), gameServerPort);
            UdpMediator udpMediator      = new UdpMediator();

            log.Info("Установка прослушки udp.");
            UdpClient udpClient = new UdpClient
            {
                Client =
                {
                    Blocking = false
                }
            };

            udpClient.Connect(serverIpEndPoint);
            udpClientWrapper = new BattleUdpClientWrapper(udpMediator, udpClient);
            udpSendUtils     = new UdpSendUtils(matchId, udpClientWrapper);
            udpMediator.Initialize(udpSendUtils, matchId);
            udpClientWrapper.StartReceiveThread();
        }
Ejemplo n.º 2
0
 public BattleUdpClientWrapper(UdpMediator udpMediator, UdpClient udpClient)
     : base(udpClient)
 {
     this.udpMediator = udpMediator;
 }