void HandleHostMatch(object Sender, EventArgs E)
        {
            NetworkContext context = null;

            try
            {
                context = NetworkContext.CreateServer(GameData.OnlinePort);
            }
            catch { }
            if (context != null)
            {
                OnProgramStateTransition(
                    this, new ProgramStateTransitionEventArgs(
                        ProgramState.MATCH_LOBBY, context.MakePlayerContext(GameData.Player).MakeLobbyContext()));
            }
        }
 void HandleRemoteConnect(object Sender, ValuedEventArgs <string> E)
 {
     try
     {
         var client = NetworkContext.CreateClient(E.Value, GameData.OnlinePort);
         var lobby  = client.MakePlayerContext(GameData.Player).MakeLobbyContext();
         if (lobby != null)
         {
             OnConnectionSetup(this, new ValuedEventArgs <MatchLobbyContext>(lobby));
         }
         else
         {
             _ConnectionPane.SetError("Failed to join lobby");
             client.Close();
         }
     }
     catch
     {
         _ConnectionPane.SetError("Failed to establish connection");
     }
 }
 void HandleLogIn(object Sender, EventArgs E)
 {
     try
     {
         var client  = NetworkContext.CreateClient(_Screen.IpAddress, GameData.OnlinePort);
         var context = client.MakeLoggedInPlayerContext(_Screen.Username, _Screen.Password);
         if (context == null)
         {
             _Screen.SetError("Invalid Log In information.");
             client.Close();
         }
         else if (OnLogIn != null)
         {
             OnLogIn(this, new ValuedEventArgs <PlayerContext>(context));
         }
     }
     catch
     {
         _Screen.SetError("Could not connect to server.");
     }
 }
Пример #4
0
 void HandleRegister(object Sender, EventArgs E)
 {
     try
     {
         var client = NetworkContext.CreateClient(_Screen.IpAddress, GameData.OnlinePort);
         client.Client.MessageAdapter = new NonMatchMessageSerializer();
         client.Client.RPCHandler     = new RPCHandler();
         Player p = client.Client.Call(
             new RegisterPlayerRequest(_Screen.Username, _Screen.Password)).Get <LogInPlayerResponse>().Player;
         if (p == null)
         {
             _Screen.SetError("Unable to Register.");
             client.Close();
         }
         else if (OnRegister != null)
         {
             OnRegister(this, new ValuedEventArgs <PlayerContext>(client.MakePlayerContext(p)));
         }
     }
     catch
     {
         _Screen.SetError("Could not connect to server.");
     }
 }