internal void RemoveTab(ChatAppTab aTab) { lock (iLock) { iTabs.Remove(aTab); } Broadcast( new JsonObject{ {"type", "disconnect"}, {"sender", aTab.Id.ToString()}, }); RecountUsers(); }
public IAppTab CreateTab(IBrowserTabProxy aTabProxy, User aUser) { int id = counter++; var tab = new ChatAppTab(this, aTabProxy, id, iUserList, aUser == null ? null : aUser.Id); lock (iLock) { iTabs.Add(tab); foreach (var user in iUsers.Values) { tab.NewMessage( new JsonObject { { "type", "user"}, { "userid", user.User.Id }, { "oldValue", JsonNull.Instance }, { "newValue", UserToJson(user.User, user.TabCount > 0 ? "online" : "offline") } }); } } tab.NewMessage( new JsonObject{ {"type","login"}, {"user", UserToJson(aUser, "online")}}); RecountUsers(); return tab; }