public async Task ConnectPlayerAsync(ConnectionType connectionType, IProgress <string> prog) { if (m_user != null) { return; } IConnection connection; switch (connectionType) { case ConnectionType.Tcp: connection = await TcpConnection.ConnectAsync(this.NetStats, "CNet"); break; case ConnectionType.Direct: connection = DirectConnection.Connect(m_server.Game); break; case ConnectionType.Pipe: connection = PipeConnection.Connect(); break; default: throw new Exception(); } var user = new ClientUser(connection); user.DisconnectEvent += OnDisconnected; await user.LogOn("tomba", prog); m_user = user; if (this.UserConnected != null) { this.UserConnected(user); } user.StartProcessingMessages(); }
public async Task ConnectPlayerAsync(ConnectionType connectionType, IProgress<string> prog) { if (m_user != null) return; IConnection connection; switch (connectionType) { case ConnectionType.Tcp: connection = await TcpConnection.ConnectAsync(this.NetStats, "CNet"); break; case ConnectionType.Direct: connection = DirectConnection.Connect(m_server.Game); break; case ConnectionType.Pipe: connection = PipeConnection.Connect(); break; default: throw new Exception(); } var user = new ClientUser(connection); user.DisconnectEvent += OnDisconnected; await user.LogOn("tomba", prog); m_user = user; if (this.UserConnected != null) this.UserConnected(user); user.StartProcessingMessages(); }