public void SaveUserAccountForClient(Message receivedMessage, Guid senderId) { UserProperties userProperties = CheckType.TryAssignType <UserProperties>(receivedMessage.Data[0]); ServerAccount serverAccount = mSessionManager.GetServerAccountFromSessionId(senderId); serverAccount.UserProperties = userProperties; serverAccount.SaveCurrentAccountData(delegate(XmlDocument returnedXmlDocument){}); }
public void GetAccountForUser(string fbAccountId, string fbSessionKey, string nickName, string firstName, string lastName, string userIpAddress, string campaignId, string referrerId, Action <ServerAccount> getAccountForUserCallback) { Action <XmlDocument> getAccountForFacebookIdCallback = delegate(XmlDocument receivedXmlGetAccount) { //<Accounts> // <Account accountId="" fbaccountid="" tfaccountId="" nickname="" firstname="" lastname=""/> //</Accounts> XmlNode accountXmlNode = receivedXmlGetAccount.SelectSingleNode("Accounts/Account"); if (accountXmlNode != null) { ServerAccount serverAccount = AccountsXmlUtil.GetAccountFromXml(accountXmlNode); if (serverAccount != null) { serverAccount.IpAddress = userIpAddress; mLogger.Info("GetAccountForUser, ServerAccount: " + serverAccount.ToString()); serverAccount.SaveCurrentAccountData(delegate(XmlDocument returnedXmlDocument) { }); if (serverAccount.PaymentItemUserId.Trim().Length == 0) { mLogger.Debug("GetAccountForUser.CreatePaymentItemsAccount"); CreatePaymentItemAccountForUser(serverAccount, userIpAddress, getAccountForUserCallback); } else { mLogger.Debug("GetAccountForUser, calling callback"); getAccountForUserCallback(serverAccount); } } else { StateServerAssert.Assert(new Exception("Could not extract the account from the Xml")); } } else { CreateAccountForUser(fbAccountId, fbSessionKey, nickName, firstName, lastName, userIpAddress, campaignId, referrerId, delegate(ServerAccount newServerAccount) { getAccountForUserCallback(newServerAccount); } ); } }; try { CallGetServerAccountForFacebookIdService(fbAccountId, getAccountForFacebookIdCallback); } catch (System.Exception) { mLogger.Warn("Could not get an account for facebook id: " + fbAccountId); getAccountForUserCallback(null); } }
protected void JoinRoom(Guid sessionId, RoomId newRoomId, Hangout.Shared.Action userJoinedRoomCallback) { GetRoomFromRoomId(newRoomId, delegate(IServerDistributedRoom serverDistributedRoomToJoin) { if (serverDistributedRoomToJoin != null) { if (!mRoomIdToRoomDistributedObject.ContainsKey(serverDistributedRoomToJoin.RoomId)) { AddRoomToRoomManager(serverDistributedRoomToJoin); } List <DistributedObjectId> distributedObjectsAssociatedWithSession = mServerStateMachine.ServerObjectRepository.GetDistributedObjectIdsOwnedBySessionId(sessionId); //find the zone for the new room the client wants to join ZoneId zoneIdToJoin = mServerStateMachine.ServerObjectRepository.GetZone(serverDistributedRoomToJoin); SendMessageToClient(BeginLoadingRoomMessage(newRoomId), sessionId); //open interest in the zones that the new room belongs to AddUserSessionToRoom(sessionId, serverDistributedRoomToJoin); //move any distributed objects belonging to the client from the old zone to the new zone foreach (DistributedObjectId distributedObjectId in distributedObjectsAssociatedWithSession) { mServerStateMachine.ServerEngine.ProcessZoneChange((ServerDistributedObject)mServerStateMachine.ServerObjectRepository.GetObject(distributedObjectId), zoneIdToJoin); } // Save room id as LastRoomId for account ServerAccount account = mServerStateMachine.SessionManager.GetServerAccountFromSessionId(sessionId); account.LastRoomId = newRoomId; if (account != null) { account.UserProperties.SetProperty(UserAccountProperties.LastRoomId, newRoomId); account.SaveCurrentAccountData(delegate(XmlDocument returnedXml) { }); } BossServerAPI.UpdateSession(account.AccountId, sessionId.ToString(), "1", zoneIdToJoin.ToString(), mServerStateMachine.StateServerId, delegate(XmlDocument xmlDocument) { }); } userJoinedRoomCallback(); } ); }
/// <summary> /// Save the current account data to the db /// Make this virtual so we can override it in our unit tests, so we don't actually make a service call /// </summary> /// <param name="serverAccount"></param> protected virtual void SaveCurrentAccountData(ServerAccount serverAccount) { serverAccount.SaveCurrentAccountData(delegate(XmlDocument returnedXml) { }); }