private void HandleAccountLoginRequest_One(string id, string[] segments) { if (!AccountHandler.AccountOnline(segments[2])) { AccountDatabaseHandler.AttemptLogin(id, segments[2], segments[3]); } else { NetworkEventDispatcher.InvokeUserLoginEvent (new UserLoginEventArgs(id, segments[2], false, true)); } }
private void HandleFriendRequest_One(string clientId, string[] segments) { //protocol#|frndrq#|id ClientState client = ClientManager.GetClientById(clientId); string idTo = segments[2]; string cmd = string.Format("{0}{1}{2}{1}{3}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.FriendRequest), client.AccountRelative.AccountId); if (AccountHandler.AccountOnline(AccountDatabaseHandler.GetAccountNameFromId(idTo))) { ClientManager.SendMessageToClientByAccount (AccountHandler.GetAccountById(idTo), cmd); } }
private void HandleFriendAddition_One(string clientId, string[] segments) { try //protocol#|adfrnd#|id { string idFrom = ClientManager.GetClientById(clientId).AccountRelative.AccountId; string idTo = segments[2]; AccountDatabaseHandler.AddFriendRelationship(idFrom, idTo); AccountDatabaseHandler.AddFriendRelationship(idTo, idFrom); if (AccountHandler.AccountOnline(AccountDatabaseHandler.GetAccountNameFromId(idFrom))) { AccountHandler.GetAccountById(idFrom).AddFriend(idTo); } if (AccountHandler.AccountOnline(AccountDatabaseHandler.GetAccountNameFromId(idTo))) { AccountHandler.GetAccountById(idTo).AddFriend(idFrom); } string cmd = string.Format("{0}{1}{2}{1}{3}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.AddFriend), idTo); ClientManager.SendMessageToClientByAccount (AccountHandler.GetAccountById(idFrom), cmd); cmd = string.Format("{0}{1}{2}{1}{3}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.AddFriend), idFrom); ClientManager.SendMessageToClientByAccount (AccountHandler.GetAccountById(idTo), cmd); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
private void HandleFriendRemoval_One(string clientId, string[] segments) { //protocol#|rmfrnd#|id string idTo = segments[2]; string idFrom = ClientManager.GetClientById(clientId).AccountRelative.AccountId; AccountDatabaseHandler.RemoveUserRelationships(idFrom, idTo); AccountDatabaseHandler.RemoveUserRelationships(idTo, idFrom); string cmd = string.Format("{0}{1}{2}{1}{3}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.RemoveFriend), idFrom); if (AccountHandler.AccountOnline(AccountDatabaseHandler.GetAccountNameFromId(idTo))) { ClientManager.SendMessageToClientByAccount(AccountHandler.GetAccountById(idTo), cmd); } }