private void ICD_ChatRoomList(int clientID, HEADER obj) { List <RoomInfo> vec = new List <RoomInfo>(); foreach (var item in mRooms) { if (!item.Value.IsUser(obj.msgUser)) { continue; } RoomInfo info = new RoomInfo(); ChatRoomInfo room = item.Value.GetRoomInfo(); info.recordID = room.body.recordID; info.state = item.Value.GetUserState(obj.msgUser); info.users = room.body.users; vec.Add(info); } if (vec.Count > 0) { ChatRoomList msg = new ChatRoomList(1); msg.FillServerHeader(DEF.CMD_ChatRoomList, 0); msg.body = vec.ToArray(); sendMsg(obj.msgUser, msg); } }
private void ProcInUser(ChatRoomInfo obj) { UpdateTick(obj.msgUser); ChatRoomInfo msg = GetRoomInfo(); BroadcastRoomInfo(msg); }
void UIFormControl_OnBeforeDataRetrieval(object sender, EventArgs e) { // Set site id and other data if the room is new if ((UIContext.EditedObject == null) || (((ChatRoomInfo)UIContext.EditedObject).ChatRoomID <= 0)) { IDataContainer data = UIFormControl.Data; data["ChatRoomCreatedByChatUserID"] = ChatUserHelper.GetChatUserFromCMSUser().ChatUserID; data["ChatRoomCreatedWhen"] = DateTime.Now; // GETDATE() will be used on SQL Server side data["ChatRoomSiteID"] = SiteID; Guid guid = Guid.NewGuid(); data["ChatRoomGUID"] = guid; EditingFormControl passwordEditingControl = UIFormControl.FieldEditingControls["chatroompassword"]; string password = passwordEditingControl.Value.ToString(); passwordEditingControl.Value = ChatRoomHelper.GetRoomPasswordHash(password, guid); } else { ChatRoomInfo room = UIContext.EditedObject as ChatRoomInfo; EditingFormControl enabledControl = UIFormControl.FieldEditingControls["chatroomenabled"]; bool enabled = (bool)enabledControl.Value; if (room.ChatRoomEnabled != enabled) { if (enabled) { ChatRoomHelper.EnableChatRoom(room.ChatRoomID); } else { ChatRoomHelper.DisableChatRoom(room.ChatRoomID); } } } }
private void DlgChatRoom_Load(object sender, EventArgs e) { InitListViews(); ICDPacketMgr.GetInst().OnRecv += OnProcChatRoom; FormClosed += delegate { ICDPacketMgr.GetInst().OnRecv -= OnProcChatRoom; ChatRoomInfo msgOut = new ChatRoomInfo(); msgOut.FillClientHeader(DEF.CMD_HideChat, 0); msgOut.body.recordID = mRoomID; ICDPacketMgr.GetInst().sendMsgToServer(msgOut); }; ChatRoomInfo msgAll = new ChatRoomInfo(); msgAll.FillClientHeader(DEF.CMD_ChatMsgAll, 0); msgAll.body.recordID = mRoomID; ICDPacketMgr.GetInst().sendMsgToServer(msgAll); ChatRoomInfo msgIn = new ChatRoomInfo(); msgIn.FillClientHeader(DEF.CMD_ShowChat, 0); msgIn.body.recordID = mRoomID; ICDPacketMgr.GetInst().sendMsgToServer(msgIn); }
private void ProcOutUser(ChatRoomInfo obj) { if (mUsers.ContainsKey(obj.msgUser)) { mUsers[obj.msgUser] = mMessages.Count; } }
private void TaskWindow_Load(object sender, EventArgs e) { InitListViews(); updateTaskInfo(); if (mTask.director == MyInfo.mMyInfo.userID && mTask.director != mTask.worker) { btnReport.Text = "확인"; btnReport.Enabled = (mTask.state == "완료대기") ? true : false; } ICDPacketMgr.GetInst().OnRecv += OnRecvEditTask; FormClosed += delegate { ICDPacketMgr.GetInst().OnRecv -= OnRecvEditTask; ChatRoomInfo msgOut = new ChatRoomInfo(); msgOut.FillClientHeader(DEF.CMD_HideChat, 0); msgOut.body.recordID = mTask.chatID; ICDPacketMgr.GetInst().sendMsgToServer(msgOut); }; ChatRoomInfo msgAll = new ChatRoomInfo(); msgAll.FillClientHeader(DEF.CMD_ChatMsgAll, 0); msgAll.body.recordID = mTask.chatID; ICDPacketMgr.GetInst().sendMsgToServer(msgAll); ChatRoomInfo msgIn = new ChatRoomInfo(); msgIn.FillClientHeader(DEF.CMD_ShowChat, 0); msgIn.body.recordID = mTask.chatID; ICDPacketMgr.GetInst().sendMsgToServer(msgIn); }
private void ProcMessageAll(ChatRoomInfo obj) { ChatRoomInfo msg = GetRoomInfo(true); msg.body.state = GetUserState(obj.msgUser); MsgCtrl.GetInst().sendMsg(obj.msgUser, msg); }
private void ProcMsgList(ChatRoomInfo msg) { if (msg.body.mesgs == null) { return; } foreach (var chat in msg.body.mesgs.Reverse()) { int msgID = chat.recordID; if (mMsgList.ContainsKey(msgID)) { mMsgList[msgID].tick = chat.tick; mMsgList[msgID].isSignaled = true; } else { ChatRoom.MsgInfo item = new ChatRoom.MsgInfo(); item.msgID = msgID; item.tick = chat.tick; item.time = chat.time; item.user = chat.user; item.message = chat.message; item.isSignaled = true; item.index = mMsgList.Count; mMsgList[msgID] = item; } UpdateMsgListView(msgID); } }
protected void Page_Load(object sender, EventArgs e) { // Get information about chat room this window has been opened for. int roomId = QueryHelper.GetInteger("windowroomid", 0); try { ChatUserHelper.VerifyChatUserHasJoinRoomRights(roomId); } catch (ChatServiceException) { DisplayError(); return; } ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomId); if (room == null) { DisplayError(); return; } // Script references insertion ScriptHelper.RegisterJQuery(Page); ChatScriptHelper.RegisterChatManager(Page); ChatScriptHelper.RegisterChatNotificationManager(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/jquery/jquery-resize.js"); ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/Chat/Pages/Scripts/ChatRoomWindow.js"); SetWebpartsUp(room.ChatRoomIsSupport); lblTitle.Text = HTMLHelper.HTMLEncode(room.ChatRoomDisplayName) + " – " + GetString(room.ChatRoomIsSupport ? "chat.title.support" : "chat.title.privateconversation"); string json = JsonConvert.SerializeObject( new { roomId, pnlChatRoomWindowClientId = pnlChatRoomWindow.ClientID, pnlTopClientId = pnlTop.ClientID, pnlBottomClientId = pnlBottom.ClientID, ChatRoomMessagesClientId = ChatRoomMessagesElem.ClientID, btnCloseClientId = btnCloseWindow.ClientID, isSupport = room.ChatRoomIsSupport, notificationManagerOptions = new { eventName = "newmessage", soundFile = ChatSettingsProvider.EnableSoundSupportChat ? ResolveUrl("~/CMSModules/Chat/CMSPages/Sound/Chat_message.mp3") : String.Empty, notifyTitle = GetString("chat.general.newmessages") }, title = lblTitle.Text }, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml } ); string startupScript = String.Format("ChatSupportWindow({0});", json); ScriptHelper.RegisterStartupScript(Page, typeof(string), "ChatSupportWindow", startupScript, true); }
private void BroadcastRoomInfo(ChatRoomInfo msg) { foreach (var user in mUsers) { msg.body.state = GetUserState(user.Key); MsgCtrl.GetInst().sendMsg(user.Key, msg); } }
private void btnExit_Click(object sender, EventArgs e) { ChatRoomInfo msg = new ChatRoomInfo(); msg.FillClientHeader(DEF.CMD_DelChatUsers, 0); msg.body.recordID = mRoomID; msg.body.users = new string[1]; msg.body.users[0] = MyInfo.mMyInfo.userID; ICDPacketMgr.GetInst().sendMsgToServer(msg); Close(); }
public void DelTask(ChatRoomInfo obj) { DatabaseMgr.DelChatTasks(obj); foreach (int id in obj.body.taskIDs) { string taskID = id.ToString(); if (mTaskIDs.ContainsKey(taskID)) { mTaskIDs.Remove(taskID); } } }
public Message CreateHelloMessage() { Message message = new Message(network, MessageType.Hello); HelloInfo hello = new HelloInfo(); List <ConnectionInfo> connections = new List <ConnectionInfo>(); List <ChatRoomInfo> rooms = new List <ChatRoomInfo>(); List <MemoInfo> memos = new List <MemoInfo>(); foreach (INodeConnection con in network.Connections) { if (con.ConnectionState == ConnectionState.Ready | con.ConnectionState == ConnectionState.Remote) { ConnectionInfo n = new ConnectionInfo(); Node ConnectionSourceNode = con.NodeLocal; Node ConnectionDestNode = con.NodeRemote; n.SourceNodeID = ConnectionSourceNode.NodeID; n.SourceNodeNickname = ConnectionSourceNode.NickName; n.DestNodeID = ConnectionDestNode.NodeID; n.DestNodeNickname = ConnectionDestNode.NickName; connections.Add(n); } } foreach (ChatRoom currentRoom in network.ChatRooms) { ChatRoomInfo tmpRoom = new ChatRoomInfo(); tmpRoom.Id = currentRoom.Id; tmpRoom.Name = currentRoom.Name; tmpRoom.Users = new string[currentRoom.Users.Count]; int x = 0; foreach (Node node in currentRoom.Users.Values) { tmpRoom.Users[x] = node.NodeID; x++; } rooms.Add(tmpRoom); } foreach (Memo currentMemo in network.Memos) { MemoInfo info = new MemoInfo(currentMemo); memos.Add(info); } hello.KnownConnections = connections.ToArray(); hello.KnownChatRooms = rooms.ToArray(); hello.KnownMemos = memos.ToArray(); hello.MyNickName = network.LocalNode.NickName; message.Content = hello; return(message); }
private void ICD_ProcChat(int clientID, HEADER obj) { ChatRoomInfo msg = (ChatRoomInfo)obj; if (!mRooms.ContainsKey(msg.body.recordID)) { LOG.warn(); return; } mRooms[msg.body.recordID].ProcChat(msg); }
protected void Page_Load(object sender, EventArgs e) { int roomID = QueryHelper.GetInteger("roomid", 0); ChatRoomMessages.RoomID = roomID; ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(roomID); if (room != null) { ChatOnlineUserHelper.LogInCurrentCMSUser(); ChatRoomUserHelper.JoinUserToRoom(room.ChatRoomID, ChatUserHelper.GetChatUserFromCMSUser(), room.ChatRoomPassword, false); } ChatRoomUsers.ChatUserTransformationName = "Chat.Transformations.CMSChatRoomUser"; ChatRoomUsers.EnableFiltering = true; ChatRoomUsers.ShowFilterItems = 20; ChatRoomUsers.EnablePaging = true; ChatRoomUsers.PagingItems = 30; ChatRoomUsers.ChatErrorDeleteAllButtonTransformationName = "Chat.Transformations.CMSChatErrorDeleteAllButton"; ChatRoomUsers.ChatErrorTransformationName = "Chat.Transformations.CMSChatError"; ChatRoomUsers.ChatMessageTransformationName = "Chat.Transformations.CMSChatMessage"; ChatRoomUsers.ChatRoomUserTransformationName = "Chat.Transformations.CMSChatRoomUser"; RoomName.ChatRoomNameTransformationName = "Chat.Transformations.CMSRoomName"; RoomName.DisplayInitialTitle = false; ChatNotification.NotificationTransformation = "Chat.Transformations.CMSChatNotification"; ChatNotification.ChatErrorDeleteAllButtonTransformationName = "Chat.Transformations.CMSChatErrorDeleteAllButton"; ChatNotification.ChatErrorTransformationName = "Chat.Transformations.CMSChatError"; ChatNotification.ChatMessageTransformationName = "Chat.Transformations.CMSChatMessage"; ChatNotification.ChatRoomUserTransformationName = "Chat.Transformations.CMSChatRoomUser"; ChatNotification.EnableNotificationBubble = false; ChatErrors.ErrorTransformationName = "Chat.Transformations.CMSChatError"; ChatErrors.ShowDeleteAllBtn = true; ChatErrors.ButtonDeleteAllTransformationName = "Chat.Transformations.CMSChatErrorDeleteAllButton"; ChatRoomMessages.ChatMessageTransformationName = "Chat.Transformations.CMSChatMessage"; ChatRoomMessages.Count = 100; ChatRoomMessages.Direction = ChatRoomMessagesDirectionEnum.Down; // Registration to chat webservice AbstractCMSPage cmsPage = this.Page as AbstractCMSPage; if (cmsPage != null) { ChatHelper.RegisterChatSupportAJAXProxy(cmsPage); } }
public void AddTask(ChatRoomInfo obj) { if (obj.body.taskIDs == null) { return; } DatabaseMgr.AddChatTasks(obj); foreach (int id in obj.body.taskIDs) { string taskID = id.ToString(); mTaskIDs[taskID] = id; } }
private void btnExit_Click(object sender, EventArgs e) { string me = MyInfo.mMyInfo.userID; if (mTask.director != me && mTask.worker != me) { ChatRoomInfo msg = new ChatRoomInfo(); msg.FillClientHeader(DEF.CMD_DelChatUsers, 0); msg.body.recordID = mTask.chatID; msg.body.users = new string[1]; msg.body.users[0] = me; ICDPacketMgr.GetInst().sendMsgToServer(msg); } Close(); }
private void SendChatMessage(string message, bool isSystem = false) { ChatRoomInfo msg = new ChatRoomInfo(); msg.FillClientHeader(DEF.CMD_ChatMsg, 0); if (isSystem) { msg.msgUser = "******"; } msg.body.recordID = mTask.chatID; msg.body.mesgs = new MesgInfo[1]; msg.body.mesgs[0] = new MesgInfo(); msg.body.mesgs[0].message = message; ICDPacketMgr.GetInst().sendMsgToServer(msg); }
private void ProcAddUsers(ChatRoomInfo obj) { foreach (string name in obj.body.users) { if (mUsers.ContainsKey(name)) { continue; } mUsers[name] = mMessages.Count; } DatabaseMgr.AddChatUsers(obj); BroadcastRoomInfo(GetRoomInfo()); }
private void btnUser_Click(object sender, EventArgs e) { DlgEditChatUsers dlg = new DlgEditChatUsers(mRoomID); dlg.ShowDialog(); string[] pre = dlg.mChatUserList; string[] after = dlg.mChatNewList; if (pre == null || after == null) { LOG.warn(); return; } { ChatRoomInfo msg = new ChatRoomInfo(); msg.FillClientHeader(DEF.CMD_DelChatUsers, 0); msg.body.recordID = mRoomID; List <string> oldUsers = new List <string>(); foreach (string item in pre) { if (!after.Contains(item)) { oldUsers.Add(item); } } msg.body.users = oldUsers.ToArray(); ICDPacketMgr.GetInst().sendMsgToServer(msg); } { ChatRoomInfo msg = new ChatRoomInfo(); msg.FillClientHeader(DEF.CMD_AddChatUsers, 0); msg.body.recordID = mRoomID; List <string> newUsers = new List <string>(); foreach (string item in after) { if (!pre.Contains(item)) { newUsers.Add(item); } } msg.body.users = newUsers.ToArray(); ICDPacketMgr.GetInst().sendMsgToServer(msg); } }
private void DlgEditChatUsers_Load(object sender, EventArgs e) { InitListViews(); InitUserAll(); ICDPacketMgr.GetInst().OnRecv += OnProcUserList; FormClosed += delegate { ICDPacketMgr.GetInst().OnRecv -= OnProcUserList; }; ChatRoomInfo msg = new ChatRoomInfo(); msg.FillClientHeader(DEF.CMD_ChatRoomInfo, 0); msg.body.recordID = mRoomID; ICDPacketMgr.GetInst().sendMsgToServer(msg); }
private void btnSend_Click(object sender, EventArgs e) { if (tbMsg.Text.Length == 0) { return; } ChatRoomInfo msg = new ChatRoomInfo(); msg.FillClientHeader(DEF.CMD_ChatMsg, 0); msg.body.recordID = mRoomID; msg.body.mesgs = new MesgInfo[1]; msg.body.mesgs[0] = new MesgInfo(); msg.body.mesgs[0].message = tbMsg.Text; ICDPacketMgr.GetInst().sendMsgToServer(msg); tbMsg.Text = ""; }
private void ProcMessage(ChatRoomInfo obj) { DataRow row = DatabaseMgr.PushChatMessage(obj); int msgID = (int)row["recordID"]; MsgInfo item = new MsgInfo(); item.msgID = msgID; item.time = obj.msgTime; item.user = obj.msgUser; item.tick = mUsers.Count - CountLoginUser(); item.message = obj.body.mesgs[0].message; item.isSignaled = true; mMessages.Add(item); ChatRoomInfo msg = GetRoomInfo(); BroadcastRoomInfo(msg); }
private void AddUsers(ChatRoomInfo obj) { if (obj.body.users == null) { return; } foreach (string name in obj.body.users) { if (mUsers.ContainsKey(name)) { continue; } mUsers[name] = mMessages.Count; } DatabaseMgr.AddChatUsers(obj); }
public void ProcChat(ChatRoomInfo obj) { //if (!mUsers.ContainsKey(obj.msgUser)) //{ // return; //} switch (obj.msgID) { case DEF.CMD_ChatMsg: ProcMessage(obj); break; case DEF.CMD_ChatMsgAll: ProcMessageAll(obj); break; case DEF.CMD_AddChatUsers: ProcAddUsers(obj); break; case DEF.CMD_DelChatUsers: ProcDelUser(obj); break; case DEF.CMD_ShowChat: ProcInUser(obj); break; case DEF.CMD_HideChat: ProcOutUser(obj); break; case DEF.CMD_ChatRoomInfo: ProcRoomInfo(obj); break; default: LOG.warn(); break; } }
public int Compare(ChatRoomInfo x, ChatRoomInfo y) { if (x == null || y == null) { return(-1); } if (x.IsPasswordProtected != y.IsPasswordProtected) { return(x.IsPasswordProtected.CompareTo(y.IsPasswordProtected)); } else if (x.Name != y.Name) { return(string.Compare(x.Name, y.Name, StringComparison.Ordinal)); } else { return(0); } }
private void OnProcUserList(int id, HEADER obj) { ChatRoomInfo msg = (ChatRoomInfo)obj; if (msg.body.users == null || msg.body.users.Length == 0) { LOG.warn(); return; } int cnt = msg.body.users.Length; mChatUserList = new string[cnt]; for (int i = 0; i < cnt; ++i) { string name = msg.body.users[i]; mChatUserList[i] = name; lvCurUsers.Items.Add(name); } }
private void ProcDelUser(ChatRoomInfo obj) { foreach (string name in obj.body.users) { if (!mUsers.ContainsKey(name)) { continue; } UpdateTick(name); mUsers.Remove(name); ChatRoomInfo msg = new ChatRoomInfo(); msg.FillServerHeader(DEF.CMD_DelChatUsers, 0); msg.body.recordID = mRoomID; MsgCtrl.GetInst().sendMsg(name, msg); } DatabaseMgr.DelChatUsers(obj); BroadcastRoomInfo(GetRoomInfo()); }
void Grid_OnAction(string actionName, object actionArgument) { int chatRoomID = ValidationHelper.GetInteger(actionArgument, 0); switch (actionName) { case "edit": SelectedItemID = chatRoomID; // Parent page will handle editing RaiseOnEdit(); break; case "safedelete": case "approve": ChatRoomInfo room = ChatRoomInfoProvider.GetChatRoomInfo(chatRoomID); ((CMSChatPage)Page).CheckModifyPermission(room.ChatRoomSiteID); if (actionName == "safedelete") { ChatRoomInfoProvider.SafeDelete(chatRoomID); } else { if (room.ChatRoomEnabled) { ChatRoomHelper.DisableChatRoom(chatRoomID); } else { ChatRoomHelper.EnableChatRoom(chatRoomID); } } break; } }
protected void Page_Load(object sender, EventArgs e) { ChatRoomInfo editedRoom = (ChatRoomInfo)EditedObject; InitTabs("content"); SetTabPrivate("general.general", "Edit.aspx?roomid={?roomid?}", "chat_rooms_general_tab"); if ((editedRoom != null) && !editedRoom.IsOneToOneSupport) { SetTabPrivate("general.password", "EditPassword.aspx?roomid={?roomid?}", "chat_rooms_password_tab"); } SetTabPrivate("chat.users", "ChatUser/List.aspx?roomid={?roomid?}", "chat_rooms_users_tab"); SetTabPrivate("chat.messages", "ChatMessage/List.aspx?roomid={?roomid?}", "chat_room_essages_tab"); // Show 'View' tab only if room is not disabled and is not one to one support room if ((editedRoom != null) && editedRoom.ChatRoomEnabled && !editedRoom.IsOneToOneSupport) { SetTabPrivate("general.view", "View.aspx?roomid={?roomid?}", "chat_rooms_view_tab"); } }