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; }
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; }
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; }
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; }
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); }
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); }
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); }
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); }
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); }
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; }
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()); } }
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; }
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; }
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; }