示例#1
0
        /// <summary>
        /// 客户端聊天消息
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public Task ClientSendMsgToClient(ChatMessageResult result)
        {
            var groupId = MessageHelper.GetGroupName(result.fromuser.id, result.touser.id);

            result.type    = Config.Chat_One;    //1v1
            result.msgtype = MessageType.Custom; //聊天消息,非系统消息
            result.status  = 1;
            result.msgid   = Guid.NewGuid().ToString();
            //保存到数据库
            UserBLL.AddMessage(1, result.message, result.fromuser.id, int.Parse(groupId), result.msgid);
            //发送给客户端
            return(Clients.Group(groupId).receiveMessage(result));
        }
示例#2
0
        /// <summary>
        /// 群组发送消息
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public Task ClientSendMsgToGroup(ChatMessageResult result)
        {
            var groupId = result.touser.id == 0 ? Config.Default_Group_Id : result.touser.id.ToString();

            result.type    = Config.Chat_Group;  //1v1
            result.msgtype = MessageType.Custom; //聊天消息,非系统消息
            result.status  = 1;
            result.msgid   = Guid.NewGuid().ToString();
            //保存到数据库
            UserBLL.AddMessage(1, result.message, result.fromuser.id, result.touser.id, result.msgid);
            //发送给客户端
            return(Clients.Group(groupId).receiveMessage(result));
        }