Exemplo n.º 1
0
 /// <summary>
 /// 发送消息 (群组),服务器接收的是CSChatMessage实体,他包含发送人,接收人,消息内容等信息
 /// </summary>
 /// <param name="msg"></param>
 /// <returns></returns>
 public Task ClientSendMsgToGroup(CSChatMessage msg)
 {
     //获取要推送的组织名称
     var groupName = MessageUtils.GetGroupName(msg.touser.userid.ToString());
     //附加信息,为群信息
     msg.other = new { t = MessageConfig.ClientTypeCTG };
     //普通信息类型
     msg.msgtype = CSMessageType.Custom;
     return Clients.Group(groupName).receiveMessage(msg);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 发送消息 ,服务器接收的是CSChatMessage实体,他包含发送人,接收人,消息内容等信息
 /// </summary>
 /// <param name="msg"></param>
 /// <returns></returns>
 public Task ClientSendMsgToClient(CSChatMessage msg)
 {
     var groupName = MessageUtils.GetGroupName(msg.fromuser.userid.ToString(), msg.touser.userid.ToString());
     /*
     中间处理一下消息直接转发给(A,B所在组织,即聊天窗口)
     */
     msg.other = new { t = MessageConfig.ClientTypeCTC };
     msg.msgtype = CSMessageType.Custom;//消息类型为普通消息
     return Clients.Group(groupName).receiveMessage(msg);
 }