예제 #1
0
파일: Lobby.cs 프로젝트: mikeries/Empire
        public async Task Initialize()
        {
            if (_myAddress != null)
            {
                return;     // already been initialized.
            }

            try
            {
                using (StreamSocket socket = await _connection.ConnectToTCP(_serverAddress, NetworkPorts.LobbyServerPort))
                {
                    _myAddress = socket.Information.LocalAddress.DisplayName;
                }

                await _connection.StartTCPListener(NetworkPorts.LobbyClientPort, ProcessRequest);
            } catch (Exception)
            {
                // Could not reach lobby.
                //TODO:  Create custom exceptions to be thrown by lobby and caught and handled by the gameView.
                LobbyCommandPacket packet = new LobbyCommandPacket("Client", LobbyCommands.Disconnected);
                OnLobbyCommand(packet);
            }

            return;
        }
예제 #2
0
 public async Task Initialize()
 {
     await _connection.StartTCPListener(NetworkPorts.LobbyServerPort, ProcessRequest);
 }