LogOn() public method

public LogOn ( string name, IProgress prog ) : Task
name string
prog IProgress
return Task
Beispiel #1
0
        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();
        }
Beispiel #2
0
		async Task ConnectPlayerAsyncInt()
		{
			var player = new ClientUser();
			player.DisconnectEvent += OnDisconnected;
			player.StateChangedEvent += (state) => SetLogOnText(state.ToString(), 0);

			await player.LogOn("tomba");

			GameData.Data.User = player;

			var controllable = GameData.Data.World.Controllables.FirstOrDefault();
			if (controllable != null && controllable.Environment != null)
			{
				var mapControl = App.MainWindow.MapControl;
				mapControl.IsVisibilityCheckEnabled = !GameData.Data.User.IsSeeAll;
				mapControl.Environment = controllable.Environment;
				mapControl.CenterPos = new System.Windows.Point(controllable.Location.X, controllable.Location.Y);
				mapControl.Z = controllable.Location.Z;

				if (GameData.Data.World.GameMode == GameMode.Adventure)
					App.MainWindow.FocusedObject = controllable;
			}

			if (Program.StartupStopwatch != null)
			{
				Program.StartupStopwatch.Stop();
				Trace.WriteLine(String.Format("Startup {0} ms", Program.StartupStopwatch.ElapsedMilliseconds));
				Program.StartupStopwatch = null;
			}
		}
Beispiel #3
0
		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();
		}