private void ReceievePrivateMessage(PrivateChatRequest message) { var request = message.ToChatMessage(); GlobalVariable.AddNewChat(request); OpenOrCreateChatForm(request, true); }
//private void ChatForm_Paint(object sender, PaintEventArgs e) //{ // Graphics g = e.Graphics; // g.SmoothingMode = SmoothingMode.HighQuality; // // this.chatBox_history.BackColor = Color.WhiteSmoke; // ////全屏蒙浓遮罩层 // //g.FillRectangle(new SolidBrush(Color.FromArgb(80, 255, 255, 255)), new Rectangle(0, 0, this.Width, this.chatBox_history.Top)); // //g.FillRectangle(new SolidBrush(Color.FromArgb(80, 255, 255, 255)), new Rectangle(0, this.chatBox_history.Top, this.chatBox_history.Width + this.chatBox_history.Left, this.Height - this.chatBox_history.Top)); // //线条 // // g.DrawLine(new Pen(Color.FromArgb(180, 198, 221)), new Point(0, this.chatBox_history.Top - 1), new Point(chatBox_history.Right, this.chatBox_history.Top - 1)); // // g.DrawLine(new Pen(Color.FromArgb(180, 198, 221)), new Point(0, this.chatBox_history.Bottom), new Point(chatBox_history.Right, this.chatBox_history.Bottom)); //} /// <summary> /// 发送聊天信息 /// </summary> /// <param name="receieveUserName"></param> /// <param name="msg"></param> private bool SendMessageCommand(ChatMessage chatMessage) { var chatType = GlobalVariable.GetChatType(chatMessage.ReceieveUserName); if (chatType == ChatType.PrivateChat) { if (!GlobalVariable.LoginUserInfo.AllowPrivateChat) { GlobalVariable.ShowError("您不允许发送私聊信息"); return(false); } PrivateChatRequest request = new PrivateChatRequest(); request.guid = Guid.NewGuid().ToString(); request.msg = chatMessage.Message; request.receivename = chatMessage.ReceieveUserName; request.SendDisplayName = GlobalVariable.LoginUserInfo.DisplayName; request.SendUserName = GlobalVariable.LoginUserInfo.UserName; request.clientRole = GlobalVariable.LoginUserInfo.UserType; // if (chatMessage.MessageType != MessageType.String) // { request.MessageType = chatMessage.MessageType; request.DownloadFileUrl = chatMessage.DownloadFileUrl; // } GlobalVariable.client.Send_PrivateChat(request); } else if (chatType == ChatType.TeamChat) { if (!GlobalVariable.LoginUserInfo.AllowTeamChat) { GlobalVariable.ShowError("您不允许发送群聊信息"); return(false); } var chat = GlobalVariable.GetChatStoreByUserName(chatMessage.ReceieveUserName); TeamChatRequest request = new TeamChatRequest(); request.groupname = chat.ChatDisplayName; request.groupuserList = chat.GetUserNames(); request.msg = chatMessage.Message; request.username = GlobalVariable.LoginUserInfo.UserName; request.groupid = chatMessage.ReceieveUserName; request.SendDisplayName = GlobalVariable.LoginUserInfo.DisplayName; request.clientRole = GlobalVariable.LoginUserInfo.UserType; request.MessageType = chatMessage.MessageType; request.DownloadFileUrl = chatMessage.DownloadFileUrl; GlobalVariable.client.Send_TeamChat(request); // GlobalVariable.client.SendMessage(request, CommandType.TeamChat); } else if (chatType == ChatType.GroupChat) { var request = new GroupChatRequest(); request.msg = chatMessage.Message; request.SendDisplayName = GlobalVariable.LoginUserInfo.DisplayName; request.SendUserName = groupId; request.clientRole = GlobalVariable.LoginUserInfo.UserType; request.MessageType = chatMessage.MessageType; request.DownloadFileUrl = chatMessage.DownloadFileUrl; GlobalVariable.client.Send_GroupChat(request); } // GlobalVariable.AddPrivateChatToChatList(_userName, GlobalVariable.LoginUserInfo.DisplayName, msg); return(true); }
public void Send_PrivateChat(PrivateChatRequest request) { SendMessage <PrivateChatRequest> message = new SendMessage <PrivateChatRequest>(); message.Action = (int)CommandType.PrivateChat; message.Data = request; Task.Run(async() => { await this.SendMessage(message); }); }
private void SendMessage(string msg) { PrivateChatRequest request = new PrivateChatRequest(); request.guid = Guid.NewGuid().ToString(); request.msg = msg; request.receivename = _userName; request.sendname = GlobalVariable.LoginUserInfo.DisplayName; GlobalVariable.client.Send_PrivateChat(request); // GlobalVariable.AddPrivateChatToChatList(_userName, GlobalVariable.LoginUserInfo.DisplayName, msg); }
public void AddReceivedMsg(PrivateChatRequest response) { ChatBoxContent content = new ChatBoxContent(response.msg, messageFont, Color.Black); var showTime = DateTime.Now.ToLongTimeString(); this.chatBox_history.AppendRichText(string.Format("{0} {1}\n", response.sendname, showTime), new Font(this.messageFont, FontStyle.Regular), Color.Blue); content.Text = " " + content.Text.Replace("\n", "\n "); this.chatBox_history.AppendChatBoxContent(content); this.chatBox_history.AppendText("\n"); this.chatBox_history.Select(this.chatBox_history.Text.Length, 0); this.chatBox_history.ScrollToCaret(); }
private void button1_Click(object sender, System.EventArgs e) { PrivateChatRequest q = new PrivateChatRequest(); q.clientRole = ClientRole.Teacher; q.guid = Guid.NewGuid().ToString(); q.MessageType = MessageType.String; q.msg = DateTime.Now.Ticks.ToString(); q.receivename = "stu001"; q.SendDisplayName = GlobalVariable.LoginUserInfo.DisplayName; q.SendUserName = GlobalVariable.LoginUserInfo.UserName; GlobalVariable.client.Send_PrivateChat(q); }
//public static AddChatRequest ToAddChatRequest(this PrivateChatRequest response) //{ // AddChatRequest request = new AddChatRequest(); // request.UserName = response.SendUserName; // request.DisplayName = response.SendDisplayName; // request.ChatType = ChatType.PrivateChat; // request.Message = response.msg; // request.UserType = response.clientRole; // return request; //} public static ChatMessage ToChatMessage(this PrivateChatRequest response) { ChatMessage request = new ChatMessage(); request.SendUserName = response.SendUserName; request.SendDisplayName = response.SendDisplayName; request.ChatType = ChatType.PrivateChat; request.Message = response.msg; request.UserType = response.clientRole; request.DownloadFileUrl = response.DownloadFileUrl; request.MessageType = response.MessageType; request.ReceieveUserName = response.receivename; return(request); }
/// <summary> /// 接收到私聊信息 /// </summary> /// <param name="privateChatResponse"></param> private void AppendToPrivateForm(PrivateChatRequest privateChatResponse) { AddChatRequest request = privateChatResponse.ToAddChatRequest(); GlobalVariable.AddNewChat(request); if (CheckChatFormIsOpen()) { // chatForm.DoReveieveMessage(request); OpenOrCreateChatForm(request, true); } else { OpenOrCreateChatForm(request, true); // ShowNotify(request); } }
private void SendPrivateMsg() { string msg = PrivateContentRtb.Text.Trim(); if (msg != "") { PrivateChatRequest request = new PrivateChatRequest(); request.guid = Guid.NewGuid().ToString(); request.msg = msg; request.receivename = _userName; request.SendDisplayName = GlobalVariable.LoginUserInfo.DisplayName; request.SendUserName = GlobalVariable.LoginUserInfo.UserName; GlobalVariable.client.Send_PrivateChat(request); // GlobalVariable.AddPrivateChatToChatList(_userName, GlobalVariable.LoginUserInfo.DisplayName, msg); PrivateContentRtb.Text = ""; PrivateHistRtb.AppendText(request.SendDisplayName + " " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n" + request.msg + "\r\n\r\n"); } }
/// <summary> /// 私聊 /// </summary> /// <param name="request"></param> public void Send_PrivateChat(PrivateChatRequest request) { SendMessage(request, CommandType.PrivateChat); }