Websockets

  • Full duplex messaging
  • No 6 connection limit
  • Multi data-type support
  • TCP socket upgrade: A standardized way to use one TCP socket through which messages can be sent from server to client and vice versa.
  • WS protocol

Microsoft.AspNetCore.WebSockets

  • Contains a managed implementation of the WebSocket protocol, along with server integration components.
  • Microsoft.AspNetCore.WebSockets
  • Microsoft.AspNetCore.WebSockets.Protocol
  • Microsoft.AspNetCore.WebSockets.Server
  • Microsoft.AspNetCore.WebSockets.Test.WebSocketMiddlewareTests src
  • middleware src and tests src
  • Using WebSockets in ASP.NET Core blog June, 2016
  • Websockets in Asp.Net Core blog July 2018
  • Archived Implementation of the WebSocket protocol for aspnet, along with client and server integration components.
  • asp net core api
    • configure app.UseWebSockets(new WebSocketOptions{ KeepAliveInterval = TimeSpan.FromSeconds(120), ReceiveBufferSize = 4*1024 })
    • controller
      var context = _httpContextAccessor.HttpContext;
      if (context.WebSockets.IsWebSocketRequest)
      {
          var ws = await context.WebSockets.AcceptWebSocketAsync();
          await SendEvents(ws, params object[] ...)
          await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "done", CancellationToken.None);
      }
      else
      {
          context.Response.StatusCode = 400;
      }
    

send.events.async.png

  • javascript js.fetch.listen.PNG

browser

  • The WebSocket browser API.
  • The WebSocket API is an advanced technology that makes it possible to open a two-way interactive communication session between the user’s browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
  • Bringing Sockets to the Web 2010
  • desktop to web socket 2012

SignalR

SignalR signalr page

misc

  • SuperWebSocket A .NET server side implementation of WebSocket protocol. repo SuperWebSocket is a .NET implementation of WebSocket server. supersocket an extensible socket server framework, telnet example
  • C# Websockets for all platforms using native bridges NVentimiglia/Websockets.PCL
  • Building Real-time Web Apps with ASP .NET WebAPI and WebSockets blog article July 17, 2012
  • Microsoft.AspNetCore.Http.WebSocketManager src
  • Microsoft.AspNetCore.TestHost.WebSocketClient src

radu matei

  • Simple middlware for real-time .NET Core samples
  • blog