public UserAction(UserAction userAction) { UserId = userAction.UserId; ActionType = userAction.ActionType; Room = userAction.Room; TimeStamp = userAction.TimeStamp; TargetUserId = userAction.TargetUserId; }
public void UserChanged(UserAction action) { switch (action.ActionType) { case UserActionType.Enter: if (UserEntered != null) UserEntered(action); break; case UserActionType.StatusChange: break; case UserActionType.Exit: if (UserExited != null) UserExited(action); break; case UserActionType.RoomEnter: if (UserEnteredRoom != null) UserEnteredRoom(action); break; case UserActionType.RoomLeave: if (UserLeftRoom != null) UserLeftRoom(action); break; } }
private void UserEntered(UserAction action) { if (isStopping) return; try { Invoke(new Action<int>(OnUserEnter), action.UserId); } catch (Exception) { } }
private void OnUserLeaveRoom(UserAction action) { var page = tabControl.TabPages[action.Room]; ChatMessagingControl chatControl = null; if (page != null) chatControl = (ChatMessagingControl) page.Controls[0]; if (action.UserId == engine.CurrentUserId) { highlightedPages.Remove(tabControl.TabPages[action.Room]); if (chatControl != null) ShowErrorInChatControl(chatControl, action.TimeStamp, "Вы перестали быть участником этой комнаты"); UpdateImageIndexForPage(action.Room); return; } // print message about leaving var user = AllUsers.Instance.GetUser(action.UserId); if (user == null) return; if (chatControl != null) PrintMessage(chatControl, new Message {Text = user.NickName + " покинул комнату", TimeStamp = action.TimeStamp}, ChatMessagingControl.MessageStyle.Notify); // remove left user from tree branch if (tabControl.SelectedTab == null || tabControl.SelectedTab.Name != action.Room) return; RemoveFromRoom("this", action.UserId.ToString()); AddToRoom("others", action.UserId.ToString(), user.NickName); }
private void OnUserEnterRoom(UserAction action) { if (action.UserId == engine.CurrentUserId) { if (!tabControl.TabPages.ContainsKey(action.Room)) // always false (obsolete code) CreatePageForRoom(action.Room); // (obsolete code) пользователь не может зайти в комнату без собственной инициативы, // а значит, вкладка этой комнаты уже существует UpdateUserTree(); UpdateImageIndexForPage(action.Room); } // print message about enetering var user = AllUsers.Instance.GetUser(action.UserId); if (user == null) return; var page = tabControl.TabPages[action.Room]; if (page != null && tabControl.SelectedTab != null && tabControl.SelectedTab.Name == action.Room) { var chatControl = (ChatMessagingControl) page.Controls[0]; PrintMessage(chatControl, new Message { Text = user.NickName + " вошел в комнату", TimeStamp = action.TimeStamp }, ChatMessagingControl.MessageStyle.Notify); } // add entered user to tree branch if (tabControl.SelectedTab == null || tabControl.SelectedTab.Name != action.Room) return; AddToRoom("this", action.UserId.ToString(), user.NickName); RemoveFromRoom("others", action.UserId.ToString()); }
private void UserLeftRoom(UserAction action) { if (isStopping) return; try { Invoke(new Action<UserAction>(OnUserLeaveRoom), action); } catch (Exception) { } }
private void UserExited(UserAction action) { if (isStopping) return; if (action.UserId != currentUserId) return; SendExited(); }
private void UserEntered(UserAction action) { if (isStopping) return; if (action.UserId != currentUserId) return; IsOnline = true; // отправляем запросы, не обработанные в предыдущем сеансе связи bool timeoutFlag; var requests = unAnsweredRequests.ExtractAll(LockTimeout, out timeoutFlag); foreach (var request in requests) chatSender.CreateRequest(request); if (Entered != null) Entered(); }