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

Microsoft.AspNet.SignalR使用cookie丢失的更多相关文章

  1. Microsoft.AspNet.SignalR 2.2

    Nuget :http://www.nuget.org/packages/Microsoft.AspNet.SignalR/ What is SignalR? ASP.NET SignalR is a ...

  2. Microsoft.AspNet.SignalR实现弹幕(即时通讯)

    引用 Microsoft.AspNet.SignalR 服务器 自定义Connection public class BarrageConnection : PersistentConnection ...

  3. 在.net4的环境下使用Microsoft.AspNet.SignalR.Client 2.4.0

    我的环境是运行在.net 4 framework,并且使用了signalr 在重连的时候发现,运行的服务被关闭了.找不到合适的处理的办法.因为报错是 说明: 由于未经处理的异常,进程终止.异常信息: ...

  4. Asp.NetCore+Microsoft.AspNetCore.SignalR前后端分离

    1.新建WebApi 2.安装Microsoft.AspNetCore.SignalR 3.新建一个集线器和消息类 using Microsoft.AspNetCore.SignalR; using ...

  5. Microsoft.AspNet.Identity 的简单使用

    要完成一个简单的注册,登陆,至少需要实现Identity中的3个接口 IUser IUserStore<TUser> : IDisposable where TUser : IUser I ...

  6. Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value '"*, Microsoft.AspNet.Mvc.TagHelpers"'

    project.json 配置: { "version": "1.0.0-*", "compilationOptions": { " ...

  7. VS2015突然报错————Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value 'Microsoft.AspNet.Mvc.Razor.TagHelpers.UrlResolutionTagHelper

    Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with ...

  8. OWIN 中 K Commands(OwinHost.exe)与 Microsoft.AspNet.Hosting 的角色问题

    问题详情:K Commands(OwinHost.exe)是不是 OWIN 中的 Host 角色?如果是,那 Microsoft.AspNet.Hosting 对应的是 OWIN 中的哪个角色? OW ...

  9. Microsoft.AspNet.Identity 自定义使用现有的表—登录实现

    Microsoft.AspNet.Identity是微软新引入的一种membership框架,也是微软Owin标准的一个实现.Microsoft.AspNet.Identity.EntityFrame ...

随机推荐

  1. laravel运行慢是怎么回事?

    因为默认的 hello 页面引用了 google 的字体,至于为什么 google 这么慢就不用我详细说明了吧.

  2. CF1088F Ehab and a weird weight formula 贪心 倍增

    CF1088F Ehab and a weird weight formula 题意 给定一棵树,点有点权,其中这棵树满足除了权值最小的点外,每个点至少有一个点权小于它的相邻点. 要求你重新构建这棵树 ...

  3. H5页面遮罩弹框下层还能滚动的问题

    在页面上显示一个遮罩层,这是非常常见的操作,在遮罩层上操作,下层也会默认跟随手指滚动 此处就是要在显示遮罩的时候禁止下层滚动. 首先设置一个全局变量 var canScroll=false; 页面初始 ...

  4. 【hdu4285】 circuits

    http://acm.hdu.edu.cn/showproblem.php?pid=4285 (题目链接) 题意 求不不能嵌套的回路个数为K的路径方案数. Solution 插头dp,时限卡得太紧了, ...

  5. Mysql分页显示

    第一部分:看一下分页的基本原理:   mysql explain SELECT * FROM message ORDER BY id DESC LIMIT 10000, 20************* ...

  6. phpredis用法笔记

    项目中用到redis集群, 发现phpredis对集群,分布式是有支持的.翻译下相关资料备用. redis扩展地址:https://github.com/phpredis/phpredis, 看到如下 ...

  7. std::async

    https://www.cnblogs.com/qicosmos/p/3534211.html https://bobjin.com/blog/c_cpp_docs/reference/en/cpp/ ...

  8. Linux应用程序设计之网络基础编程

    1.TCP/IP协议概述 1.1.OSI参考模型及TCP/IP参考模型 OSI协议参考模型是基于国际标准化组织(ISO)的建议发展起来的,从上到下工分为7层:应用层,表示层,会话层,传输层,网络层,数 ...

  9. 题解 P2486 【[SDOI2011]染色】

    写在前面 对于刚学树剖的同学比如我这种大大大蒟蒻来说,做这题会给你带来很大的提升:不仅可以对树剖有更深刻的理解,还可以更好的理解线段树,所以这是一道好题哦 为了更好懂,我一点一点说说思路吧 思路 首先 ...

  10. android中service启动后台程序

    Service是Android中一个类,它是Android四大组件之一,使用Service可以在后台执行长时间的操作( perform long-running operations in the b ...