public PinStub Pin(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(); if (!spec.CheckPermission(Usr.Current, false)) throw new ReadPermissionException(); storeRoomState(roomState, Usr.Current.K); RoomStub r; if (spec.RoomType == RoomType.BuddyAlerts && spec.ObjectK > 0) { if (spec.ObjectK == Usr.Current.K) throw new SelfPrivateChatRoomException(); spec = new Chat.RoomSpec(spec.ObjectK, Usr.Current.K); guid = spec.Guid; } if (spec.RoomType == RoomType.PrivateChat && spec.ObjectK > 0 && spec.SecondObjectK == 0) { if (spec.ObjectK == Usr.Current.K) throw new SelfPrivateChatRoomException(); spec = new Chat.RoomSpec(spec.ObjectK, Usr.Current.K); guid = spec.Guid; } if (!spec.CheckPermission(Usr.Current, false)) throw new ReadPermissionException(); lastActionTicks = resetLastActionAndSessionID(sessionID); RoomPin p = getOrCreateRoomPin(guid, null, Usr.Current.K); r = new RoomStub( clientID, guid.Pack(), spec.GetName(Usr.Current), spec.GetUrl(Usr.Current), true, spec.IsStarredByDefault, spec.IsStarredByDefault, true, spec.IsStarrable, false, false, 0, 0, "", "", "", spec.IsReadOnly, p.ListOrder, spec.IsPhotoChatRoom, spec.IsPrivateChatRoom, spec.IsNewPhotoAlertsRoom, spec.GetPrivateChatRoomPresence(Usr.Current), spec.Icon, "", "", spec.HasArchive, spec.HiddenFromRoomList, spec.IsStreamRoom); 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.PinRoom(Usr.Current.K, sessionID, lastItemGuid, ref lastItemGuidReturned, guid); PinStub ps = new PinStub(); ps.roomStub = r; ps.itemsJson = chatItems; ps.lastActionTicks = lastActionTicks; ps.lastItemGuidReturned = lastItemGuidReturned.Pack(); return ps; }
public PinStub SwitchPhotoRoom(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); int usrK = Usr.Current == null ? 0 : Usr.Current.K; if (spec == null) throw new InvalidRoomException(); if (!spec.CheckPermission(Usr.Current, false)) throw new ReadPermissionException(); storeRoomState(roomState, usrK); RoomStub r; string tokenDateTime = DateTime.Now.Ticks.ToString(); string token = Chat.GetToken(guid, tokenDateTime); //we should add the new guest room to the state stubs... StateStub ss = new StateStub(); ss.guid = roomGuid; ss.guest = true; ss.listOrder = -1; ss.tokenDateTimeTicks = tokenDateTime; ss.token = token; List<StateStub> roomStateList = roomState.ToList(); roomStateList.Add(ss); roomState = roomStateList.ToArray(); lastActionTicks = resetLastActionAndSessionID(sessionID); r = new RoomStub( clientID, guid.Pack(), spec.GetName(Usr.Current), spec.GetUrl(Usr.Current), false, spec.IsStarredByDefault, spec.IsStarredByDefault, true, spec.IsStarrable, false, true, 0, 0, "", "", "", spec.IsReadOnly, -1, spec.IsPhotoChatRoom, spec.IsPrivateChatRoom, spec.IsNewPhotoAlertsRoom, spec.GetPrivateChatRoomPresence(Usr.Current), spec.Icon, tokenDateTime, token, spec.HasArchive, spec.HiddenFromRoomList, spec.IsStreamRoom); 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(usrK, sessionID, false, lastItemGuid, ref lastItemGuidReturned); PinStub ps = new PinStub(); ps.roomStub = r; ps.itemsJson = chatItems; ps.lastActionTicks = lastActionTicks; ps.lastItemGuidReturned = lastItemGuidReturned.Pack(); return ps; }
public void PinSuccessCallback(PinStub p, object userContext, string methodName) { if (p != null) { bool excludeItemsFromPinnedRoom = false; if (GotRoom != null) excludeItemsFromPinnedRoom = GotRoom(this, new GotRoomEventArgs(p.roomStub)); processItems(p.itemsJson, p.lastActionTicks, p.lastItemGuidReturned, methodName, p.guestRefreshStubs, p.roomStub.guid, excludeItemsFromPinnedRoom); } continueProcessingCriticalRequestQueue(); }