Exemple #1
0
        /// <summary>
        /// 发送信息给特定人
        /// </summary>
        /// <param name="ToId">接收人ID</param>
        /// <param name="message">信息</param>
        public void sendMessage(string strmodel)
        {
            UserInfo = GetSignalrUserInfo();
            Friends_Chat model = JsonConvert.DeserializeObject <Friends_Chat>(strmodel);

            model.Id       = Guid.NewGuid();
            model.SenderId = UserInfo.Id;
            ReturnModel remodel = JsonConvert.DeserializeObject <ReturnModel>(oFriendsBLL.Friend_AddFriendsChatList(model).ToString());

            if (remodel.Code == 1)
            {
                var obj = new { Code = 1, Msg = "发送成功", FriendId = model.OwnerId, SenderId = model.SenderId, SendType = model.SendType, SendContent = model.SendContent, ReceiverHeadPic = UserInfo.HeadPicture, ReceiverName = UserInfo.UserName, UpdateTime = DateTime.Now.ToLongTimeString() };
                Clients.User(model.OwnerId.ToString()).sendMessage(obj);
                Clients.Caller.sendMsgTips(obj);
            }
            else
            {
                var obj = new { Code = 0, Msg = "发送失败" };
                Clients.Caller.sendMsgTips(obj);
            }
        }