zoukankan      html  css  js  c++  java
  • 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)));
    }
    }

  • 相关阅读:
    78. Subsets java solutions
    77. Combinations java solutions
    236. Lowest Common Ancestor of a Binary Tree java solutions
    86. Partition List java solutions
    39. Combination Sum java solutions
    129. Sum Root to Leaf Numbers java solutions
    杭电1004
    杭电1003
    杭电1002
    杭电1001
  • 原文地址:https://www.cnblogs.com/c-x-a/p/7366032.html
Copyright © 2011-2022 走看看