您的位置:首页 > 编程语言 > ASP

Microsoft.AspNet.SignalR使用cookie丢失

2017-08-15 16:55 281 查看

public void SendGroupMessage(string roomId, string message, string status)
{
// 调用房间内所有客户端的sendMessage方法
// 因为在加入房间的时候,已经将客户端的ConnectionId添加到Groups对象中了,所有可以根据房间名找到房间内的所有连接Id
// 其实我们也可以自己实现Group方法,我们只需要用List记录所有加入房间的ConnectionId
// 然后调用Clients.Clients(connectionIdList),参数为我们记录的连接Id数组。

var cook = JsonHelper.ToObject<LoginViewModel>(Context.User.Identity.Name);//改为这个上下文就行了,不用httpcontext.current
AspChat aspChat = new AspChat();
aspChat.RootId = Convert.ToUInt64(roomId);
aspChat.Comment = message;
aspChat.UpdateId = cook.UserId;
aspChat.UpdateTime = DateTime.Now;
//メッセージの保存
service.SaveChatRecord(aspChat, status);

if (!string.IsNullOrEmpty(message))
{
Clients.Group(roomId, new string[0]).sendMessage(cook.UserName, message, aspChat.UpdateTime.Value.ToString("yyyy-MM-dd hh:mm:ss"), Convert.ToBoolean(Convert.ToInt32(cook.IsAsp)));
}
}

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐