public UnPinStub UnPin(string clientID, string roomGuid, string lastItemGuidString, int sessionID, string lastActionTicks, string pageUrl, StateStub[] roomState) { WaitIfDevEnv(); Guid guid = roomGuid.UnPackGuid(); Chat.RoomSpec spec = Chat.RoomSpec.FromGuid(guid); if (Usr.Current == null || Usr.Current.IsSkeleton || Usr.Current.Banned) throw new LoginPermissionException(); if (spec == null) throw new InvalidRoomException(); StateStub state = null; foreach (StateStub ss in roomState) { if (ss.guid == roomGuid) { state = ss; break; } } #region Exit room on chat server only if we need to //For thread chat and PersistantAlertsRooms, we don't want to exit the room on the chat server. if (spec.RoomType == RoomType.Normal && (spec.ObjectType == Model.Entities.ObjectType.Thread || (spec.ObjectBob != null && spec.ObjectBob is IHasPrimaryThread && ((IHasPrimaryThread)spec.ObjectBob).ThreadK.IsNotNullOrZero()))) { //don't exit the room if we're watching the topic bool exitRoom = true; int threadK = spec.ObjectType == Model.Entities.ObjectType.Thread ? spec.ObjectK : ((IHasPrimaryThread)spec.ObjectBob).ThreadK.Value; try { Thread t = new Thread(threadK); ThreadUsr tu = t.GetThreadUsr(Usr.Current); if (tu != null && tu.IsWatching) exitRoom = false; } catch { } if (exitRoom) Chat.ExitRoom(guid, Usr.Current.K); } else if (!spec.IsPersistantAlertsRoom) { Chat.ExitRoom(guid, Usr.Current.K); } #endregion #region Store the un-pinned room in the database, or delete the pin record. try { RoomPin rp = new RoomPin(Usr.Current.K, guid); if (spec.IsDefaultRoom) { rp.Pinned = false; rp.Update(); } else { rp.Delete(); } } catch (BobNotFound) { if (spec.IsDefaultRoom) { RoomPin rp = new RoomPin(); rp.UsrK = Usr.Current.K; rp.RoomGuid = guid; rp.ListOrder = state != null ? state.listOrder : 0; rp.Pinned = false; rp.Starred = spec.IsStarredByDefault; rp.DateTime = DateTime.Now; rp.Update(); } } #endregion storeRoomState(roomState, Usr.Current.K); lastActionTicks = resetLastActionAndSessionID(sessionID); Guid lastItemGuidReturned = Guid.Empty; Guid lastItemGuid = lastItemGuidString.Length == 0 ? Guid.Empty : lastItemGuidString.UnPackGuid(); ChatLibrary.ChatServerInterface cs = (ChatLibrary.ChatServerInterface)Activator.GetObject(typeof(ChatLibrary.ChatServerInterface), Bobs.Vars.ChatServerAddress); string chatItems = cs.GetLatest(Usr.Current.K, sessionID, false, lastItemGuid, ref lastItemGuidReturned); UnPinStub ups = new UnPinStub(); ups.roomGuid = roomGuid; ups.itemsJson = chatItems; ups.lastActionTicks = lastActionTicks; ups.lastItemGuidReturned = lastItemGuidReturned.Pack(); return ups; }
public void UnPinSuccessCallback(UnPinStub u, object userContext, string methodName) { processItems(u.itemsJson, u.lastActionTicks, u.lastItemGuidReturned, methodName, u.guestRefreshStubs, u.roomGuid, true); continueProcessingCriticalRequestQueue(); }