一、介绍

SignalR对websocket、SSE、长连接、forever frame进行封装。

websocket(html5):ws协议,这个协议基于tcp的。也就是说和http没有关系(兼容性不好)

SSE:客户端订阅服务器的一个事件,然后方便通过这个事件推送到客户端。  server => client 

长链接:保持一次链接的时间,例如保持一个链接5s

forever frame:在body中藏一个iframe,那么这个iframe和server是一个永久链接,如果server来数据,通过这个链接推送到client

 

二、PersistentConnection

1,参数

《1》 request: 获取一些链接中的附加信息,request.querystring
        request.cookie

        request是一个katana的包装类。

        singlaR 的request 其实是asp.net 中的 Request的子集。

《2》 connectionId 这个参数就是 客户端连接到服务器的唯一标识。。。也就说这个标识标识了客户端。本质上来说,和SessionID是一个性质。 【GUID】

2,demo

using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(WebApplication1.Startup1))]

namespace WebApplication1
{
    public class Startup1
    {
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=316888
            
            app.MapSignalR<MyConnection1>("/connection");
        }
    }
}
Startup1

相关文章:

  • 2021-10-27
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2021-08-06
  • 2021-07-25
猜你喜欢
  • 2022-12-23
  • 2021-05-20
  • 2021-12-08
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案