public void ProcessDisconnectSession(Guid sessionIdToClose) { IServerDistributedRoom roomToLeave = mRoomManager.FindRoomForUser(sessionIdToClose); if (roomToLeave != null) { mRoomManager.LeaveRoom(sessionIdToClose, roomToLeave); } ServerAccount serverAccount = mSessionManager.GetServerAccountFromSessionId(sessionIdToClose); if (serverAccount != null) { BossServerAPI.RemoveSession(serverAccount.AccountId, sessionIdToClose.ToString(), delegate(XmlDocument xmlDocument) { }); } BossServerAPI.UpdateStateServer(mStateServerId, mServerMessageProcessor.ServerReflector.GetNumConnections(), "1", delegate(XmlDocument xmlDocument) { }); mServerEngine.ProcessDisconnectSession(sessionIdToClose); }
/// <summary> /// Called by ConnectionHandler on successful login /// </summary> /// <param name="sessionId"></param> /// <param name="userAccount"></param> /// <param name="facebookSessionKey"></param> /// <param name="defaultAvatarId"></param> public void ProcessUserLogin(Guid sessionId, ServerAccount userAccount, string facebookSessionKey, AvatarId defaultAvatarId, Stopwatch loginTimer) { mSessionManager.AddSession(sessionId, userAccount); BossServerAPI.RegisterNewSession(userAccount.AccountId, sessionId.ToString(), "1", ZoneId.LimboZone.ToString(), mStateServerId, delegate(XmlDocument xmlDocument) { }); BossServerAPI.UpdateStateServer(mStateServerId, mServerMessageProcessor.ServerReflector.GetNumConnections(), "1", delegate(XmlDocument xmlDocument) { }); mAvatarManager.GetAvatar(sessionId, ZoneId.LimboZone, userAccount, defaultAvatarId, delegate(bool successfullyGotAvatar) { //send an error message to the client if we can't get or create an avatar if (successfullyGotAvatar == false) { LoginError(sessionId, ErrorIndex.CannotGetOrCreateAvatar, MessageSubType.UserLoginGetOrCreateAvatarError); } else { // We got all the required data for the avatar. Send a login success message. // Check for the room and get the facebook friends in the background, as these calls take too long and aren't required to let the user continue. LoginSuccess(sessionId, loginTimer); // Check if a user has a default room, and create a room for the user if it doesn't exist mRoomManager.GetOrCreateDefaultRoomForUser(sessionId, userAccount, delegate(IServerDistributedRoom room) { if (room == null) { //send an error message to the client if we can't get or create a room LoginError(sessionId, ErrorIndex.CannotGetOrCreateRoom, MessageSubType.UserLoginGetOrCreateRoomError); } else { // Get facebook friends, and cache it on the account. We have to do this now before the session id for facebook expires mFriendsManager.GetAllFacebookFriendsForUser(sessionId, userAccount.FacebookAccountId, facebookSessionKey, delegate(List <FacebookFriendInfo> friendInfos) { userAccount.AddFacebookFriends(friendInfos); }); } }); } }); }