Microsoft.AspNet.SignalR使用cookie丢失

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)));
}
}

 

posted @ 2017-08-15 16:55  公众号python学习开发  阅读(211)  评论(0编辑  收藏  举报