Esempio n. 1
0
 public void HandleCommand(int connectionID, CommandMessage message, ClientManager manager)
 {
     if (OnTextUserMessage != null)
     {
         object[] msgParams = message.GetParams();
         OnTextUserMessage((string)msgParams[0], (Credentials)msgParams[1]);
     }
 }
Esempio n. 2
0
 public void HandleCommand(int connectionID, CommandMessage message, ClientManager manager)
 {
     if (OnLeaveGathering != null)
     {
         object[] msgParams = message.GetParams();
         OnLeaveGathering((bool)msgParams[0]);
     }
 }
Esempio n. 3
0
 public void HandleCommand(int connectionID, CommandMessage message, ClientManager manager)
 {
     if (OnSQLExecute != null)
     {
         object[] msgParams = message.GetParams();
         OnSQLExecute((int)msgParams[0]);
     }
 }
Esempio n. 4
0
 public void HandleCommand(int connectionID, CommandMessage message, ClientManager manager)
 {
     if (OnSqlData != null)
     {
         object[] msgParams = message.GetParams();
         OnSqlData((List<string>)msgParams[0], (List<List<object>>)msgParams[1]);
     }
 }
Esempio n. 5
0
 public void HandleCommand(int connectionID, CommandMessage message, ClientManager manager)
 {
     if (OnCreateLogin != null)
     {
         object[] msgParams = message.GetParams();
         OnCreateLogin((bool)msgParams[0]);
     }
 }
Esempio n. 6
0
 public void HandleCommand(int connectionID, CommandMessage message, ClientManager manager)
 {
     if (OnChangePassword != null)
     {
         object[] msgParams = message.GetParams();
         OnChangePassword((bool)msgParams[0]);
     }
 }
Esempio n. 7
0
 public void HandleCommand(int connectionID, CommandMessage message, ClientManager manager)
 {
     if (OnEmailUsername != null)
     {
         object[] msgParams = message.GetParams();
         OnEmailUsername((bool)msgParams[0]);
     }
 }
Esempio n. 8
0
 public static bool ChangePassword(string oldpass, string newpass)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.ChangePassword
     };
     command.SetParams(new object[] { oldpass, newpass });
     sChangingPassword = true;
     sChangePasswordResult = false;
     GPGnetClientLib.ClientHandlers.ChangePassword.OnChangePassword += new ChangePasswordResponse(Authentication.ChangePassword_OnChangePassword);
     ClientManager.GetManager().MessageServer(command);
     int tickCount = Environment.TickCount;
     while (sChangingPassword && ((tickCount + GPGnetClientLib.Lobby.Lobby.Timeout) > Environment.TickCount))
     {
         Thread.Sleep(10);
     }
     return sChangePasswordResult;
 }
Esempio n. 9
0
 public static bool CreateRoom(string kind, string description, string password, string[] buffer)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.CreateRoom
     };
     command.SetParams(new object[] { kind, description, password, buffer });
     sCreatingRoom = true;
     sCreateRoomResult = false;
     GPGnetClientLib.ClientHandlers.CreateRoom.OnCreateGathering += new CreateGatheringResponse(Gatherings.CreateRoom_OnCreateGathering);
     ClientManager.GetManager().MessageServer(command);
     int tickCount = Environment.TickCount;
     while (sCreatingRoom && ((tickCount + GPGnetClientLib.Lobby.Lobby.Timeout) > Environment.TickCount))
     {
         Thread.Sleep(10);
     }
     return sCreateRoomResult;
 }
Esempio n. 10
0
 public static bool EmailUsername(string cdkey)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.EmailUsername
     };
     command.SetParams(new object[] { cdkey });
     sEmailingUsername = true;
     sEmailUsernameResult = false;
     GPGnetClientLib.ClientHandlers.EmailUsername.OnEmailUsername += new EmailUsernameResponse(Authentication.EmailUsername_OnEmailUsername);
     ClientManager.GetManager().MessageServer(command);
     int tickCount = Environment.TickCount;
     while (sEmailingUsername && ((tickCount + GPGnetClientLib.Lobby.Lobby.Timeout) > Environment.TickCount))
     {
         Thread.Sleep(10);
     }
     return sEmailUsernameResult;
 }
Esempio n. 11
0
 public static bool CreateLogin(string name, string password, string email)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.CreateLogin
     };
     command.SetParams(new object[] { name, password, email });
     sCreatingLogin = true;
     sCreateLoginResult = false;
     GPGnetClientLib.ClientHandlers.CreateLogin.OnCreateLogin += new CreateLoginResponse(Authentication.CreateLogin_OnCreateLogin);
     ClientManager.GetManager().MessageServer(command);
     int tickCount = Environment.TickCount;
     while (sCreatingLogin && ((tickCount + GPGnetClientLib.Lobby.Lobby.Timeout) > Environment.TickCount))
     {
         Thread.Sleep(10);
     }
     return sCreateLoginResult;
 }
Esempio n. 12
0
 public static bool SQLExecute(string queryname, object[] args, out int rowcount)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.SQLExecute
     };
     command.SetParams(new object[] { queryname, args });
     sGettingSQLExecute = true;
     sSQLResultCount = -1;
     GPGnetClientLib.ClientHandlers.SQLExecute.OnSQLExecute += new SQLExecuteResponse(SQL.SQLExecute_OnSQLExecute);
     ClientManager.GetManager().MessageServer(command);
     int tickCount = Environment.TickCount;
     while (sGettingSQLExecute && ((tickCount + GPGnetClientLib.Lobby.Lobby.Timeout) > Environment.TickCount))
     {
         Thread.Sleep(10);
     }
     rowcount = sSQLResultCount;
     return (sSQLResultCount != -1);
 }
Esempio n. 13
0
 public static bool SQLData(string queryname, object[] args, out List<string> columns, out List<List<object>> rows)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.SQLData
     };
     command.SetParams(new object[] { queryname, args });
     sGettingSQLData = true;
     sSQLDataRows = new List<List<object>>();
     sSQLDataColumns = new List<string>();
     GPGnetClientLib.ClientHandlers.SQLData.OnSqlData += new SQLDataResponse(SQL.SQLData_OnSqlData);
     ClientManager.GetManager().MessageServer(command);
     int tickCount = Environment.TickCount;
     while (sGettingSQLData && ((tickCount + GPGnetClientLib.Lobby.Lobby.Timeout) > Environment.TickCount))
     {
         Thread.Sleep(10);
     }
     rows = sSQLDataRows;
     columns = sSQLDataColumns;
     return (sSQLDataRows != null);
 }
Esempio n. 14
0
 public static bool AdhocSQL(string SQL, out List<string> columns, out List<List<object>> rows)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.AdhocSQL
     };
     command.SetParams(new object[] { SQL });
     sGettingAdhocSQL = true;
     sAdhocRows = new List<List<object>>();
     sAdhocColumns = new List<string>();
     GPGnetClientLib.ClientHandlers.AdhocSQL.OnAdhocSQL += new AdhocSQLResponse(GPGnetClientLib.Lobby.SQL.AdhocSQL_OnAdhocSQL);
     ClientManager.GetManager().MessageServer(command);
     int tickCount = Environment.TickCount;
     while (sGettingAdhocSQL && ((tickCount + GPGnetClientLib.Lobby.Lobby.Timeout) > Environment.TickCount))
     {
         Thread.Sleep(10);
     }
     rows = sAdhocRows;
     columns = sAdhocColumns;
     return (sAdhocRows != null);
 }
Esempio n. 15
0
 private void MessageBroker_OnCommandMessage(int connectionID, CommandMessage message)
 {
     LogData(Thread.CurrentThread.ManagedThreadId.ToString() + " Server request to client: " + message.CommandName.ToString());
     object[] msgParams = message.GetParams();
     if (msgParams != null)
     {
         foreach (object obj2 in msgParams)
         {
             LogData(obj2.ToString());
         }
     }
     object[] state = new object[] { connectionID, message };
     ThreadPool.QueueUserWorkItem(delegate (object o) {
         object[] objArray = o as object[];
         int num1 = (int) objArray[0];
         CommandMessage message1 = objArray[1] as CommandMessage;
         if (this.mClientHandlers.ContainsKey(message1.CommandName))
         {
             this.mClientHandlers[message1.CommandName].HandleCommand(connectionID, message, this);
         }
     }, state);
 }
Esempio n. 16
0
 public CommandMessage GetNextMessage()
 {
     if (this.Stream.Length < 2L)
     {
         return null;
     }
     this.Stream.Position = 0L;
     BinaryReader reader = new BinaryReader(this.Stream);
     reader.ReadInt16();
     int count = 0;
     if (this.Stream.Length == 2L)
     {
         count = 2;
     }
     else
     {
         count = reader.ReadInt32();
     }
     reader = null;
     if (count > this.Stream.Length)
     {
         return null;
     }
     this.Stream.Position = 0L;
     byte[] buffer = new byte[count];
     byte[] buffer2 = new byte[this.Stream.Length - count];
     MemoryStream stream = new MemoryStream();
     this.Stream.Read(buffer, 0, count);
     if (buffer2.Length > 0)
     {
         this.Stream.Read(buffer2, 0, buffer2.Length);
         stream.Write(buffer2, 0, buffer2.Length);
     }
     this.Stream = stream;
     CommandMessage message = new CommandMessage();
     message.UnformatMessage(buffer);
     return message;
 }
Esempio n. 17
0
 public static bool Login(string name, string password)
 {
     if (LoggedIn)
     {
         throw new Exception("You are already logged in and must first logout.");
     }
     CommandMessage command = new CommandMessage {
         CommandName = Commands.Login
     };
     command.SetParams(new object[] { name, password });
     sLogginIn = true;
     sLoginResult = false;
     GPGnetClientLib.ClientHandlers.Login.OnLogin += new LoginResponse(Authentication.Login_OnLogin);
     ClientManager.GetManager().MessageServer(command);
     int tickCount = Environment.TickCount;
     while (sLogginIn && ((tickCount + GPGnetClientLib.Lobby.Lobby.Timeout) > Environment.TickCount))
     {
         Thread.Sleep(10);
     }
     return sLoginResult;
 }
Esempio n. 18
0
 public static bool ResetPassword(string username, string email)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.ResetPassword
     };
     command.SetParams(new object[] { username, email });
     sResettingPassword = true;
     sResetPasswordResult = false;
     GPGnetClientLib.ClientHandlers.ResetPassword.OnResetPassword += new ResetPasswordResponse(Authentication.ResetPassword_OnResetPassword);
     ClientManager.GetManager().MessageServer(command);
     int tickCount = Environment.TickCount;
     while (sResettingPassword && ((tickCount + GPGnetClientLib.Lobby.Lobby.Timeout) > Environment.TickCount))
     {
         Thread.Sleep(10);
     }
     return sResetPasswordResult;
 }
Esempio n. 19
0
 public void MessageServer(CommandMessage command)
 {
     LogData(Thread.CurrentThread.ManagedThreadId.ToString() + " Client request to server: " + command.CommandName.ToString());
     object[] msgParams = command.GetParams();
     if (msgParams != null)
     {
         foreach (object obj2 in msgParams)
         {
             LogData(obj2.ToString());
         }
     }
     ThreadPool.QueueUserWorkItem(delegate (object o) {
         MessageBroker.SendMessage(o as CommandMessage);
     }, command);
 }
Esempio n. 20
0
 public bool SubmitGameReport()
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.ReportSupcomGame
     };
     command.SetParams(new object[] { this.mReport });
     ClientManager.GetManager().MessageServer(command);
     this.mReport = null;
     return true;
 }
Esempio n. 21
0
 public static void TextMessage(string roomname, string message)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.TextMessageRoom
     };
     command.SetParams(new object[] { roomname, message });
     ClientManager.GetManager().MessageServer(command);
 }
Esempio n. 22
0
 public static void PrivateMessage(string username, string message)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.TextMessageUser
     };
     command.SetParams(new object[] { username, message });
     ClientManager.GetManager().MessageServer(command);
 }
Esempio n. 23
0
 public static bool LeaveRoom(string description)
 {
     CommandMessage command = new CommandMessage {
         CommandName = Commands.LeaveRoom
     };
     command.SetParams(new object[] { description });
     sLeavingRoom = true;
     sLeaveRoomResult = false;
     GPGnetClientLib.ClientHandlers.LeaveRoom.OnLeaveGathering += new LeaveGatheringResponse(Gatherings.LeaveRoom_OnLeaveGathering);
     ClientManager.GetManager().MessageServer(command);
     int tickCount = Environment.TickCount;
     while (sLeavingRoom && ((tickCount + GPGnetClientLib.Lobby.Lobby.Timeout) > Environment.TickCount))
     {
         Thread.Sleep(10);
     }
     return sLeaveRoomResult;
 }
Esempio n. 24
0
 public static void SendMessage(CommandMessage message)
 {
     Send(sClient, message.FormatMessage());
 }
Esempio n. 25
0
 private static void ReceiveCallback(IAsyncResult ar)
 {
     try
     {
         StateObject asyncState = (StateObject) ar.AsyncState;
         Socket workSocket = asyncState.workSocket;
         if (workSocket.Connected && !asyncState.ConnectionError)
         {
             int length = 0;
             try
             {
                 length = workSocket.EndReceive(ar);
             }
             catch (ObjectDisposedException)
             {
                 asyncState.ConnectionError = true;
                 ClientManager.LogData("A connection has been disposed and is no longer valid.");
                 return;
             }
             catch (SocketException)
             {
                 asyncState.ConnectionError = true;
                 ClientManager.LogData("The server has shut down.");
                 if (OnCommandMessage != null)
                 {
                     CommandMessage message = new CommandMessage {
                         CommandName = Commands.TextMessageRoom
                     };
                     Credentials credentials = new Credentials {
                         Name = "Disconnect",
                         PrincipalID = -1
                     };
                     message.SetParams(new object[] { "Disconnect", "Connection to the GPGnet server has been lost.", credentials });
                     OnCommandMessage(asyncState.ConnectionID, message);
                     message.SetParams(new object[] { "Disconnect", "Please restart GPGnet once network connectivity has been restored.", credentials });
                     OnCommandMessage(asyncState.ConnectionID, message);
                 }
                 return;
             }
             if (length > 0)
             {
                 byte[] destinationArray = new byte[length];
                 Array.Copy(asyncState.buffer, destinationArray, length);
                 asyncState.Stream.Position = asyncState.Stream.Length;
                 asyncState.Stream.Write(destinationArray, 0, destinationArray.Length);
                 try
                 {
                     for (CommandMessage message2 = asyncState.GetNextMessage(); message2 != null; message2 = asyncState.GetNextMessage())
                     {
                         if (OnCommandMessage != null)
                         {
                             OnCommandMessage(asyncState.ConnectionID, message2);
                         }
                     }
                 }
                 catch (Exception exception)
                 {
                     asyncState.ResetState();
                     ClientManager.LogData(exception);
                 }
                 workSocket.BeginReceive(asyncState.buffer, 0, 0x1000, SocketFlags.None, new AsyncCallback(MessageBroker.ReceiveCallback), asyncState);
             }
             else
             {
                 asyncState.ConnectionError = true;
                 ClientManager.LogData("Received a 0 byte disconnect from " + asyncState.ConnectionID.ToString());
             }
         }
     }
     catch (Exception exception2)
     {
         ClientManager.LogData(exception2.ToString());
     }
 }