Confused by Microsoft WebSockets namespaces

So far, in tutorials, blogs, and official documentation, I've seen:

  • Microsoft.Web.WebSockets
    • Obtained from NuGet
    • The assembly is Microsoft.WebSockets, but the Namespace is Microsoft.Web.WebSockets
    • Last updated 14 Sept 2011
    • Contains WebSocketHandler, WebSocketCollections, WebSocketExtensions
  • System.Web.WebSockets
    • Part of .NET 4.5 and available in Visual Studio 11 Developer Preview
    • Contains AspNetWebSocket, AspNetWebSocketContext, AspNetWebSocketOptions classes
    • Documentation on MSDN
  • System.Net.WebSockets
    • Thanks Ladislav Mrnka for pointing this one out
    • Part of .NET 4.5 and available in Visual Studio 11 Developer Preview
    • Contains WebSocket, HttpListenerWebSocketContext and more
    • Documentation on MSDN
  • System.ServiceModel.WebSockets
    • I must have imagined I'd seen this one somewhere, can't find it now
  • Microsoft.ServiceModel.WebSockets
    • Obtained from html5labs.interoperabilitybridges.com/....
    • Installed into [Program Files]\Microsoft SDKs\WCF WebSockets\11.06.22\bin
    • Contains WebSocketHost, WebSocketService, WebSocketsService classes, plus interfaces and collections
    • Last updated 22 June 2011

are these somehow different? Are some older versions?

I've always assumed the 'Microsoft.Web' namespace was used for pre-release code, but even the demos at the Build conference use this namespace, despite the fact that .NET 4.5 includes the System.Web.WebSockets namespace built in.

System.Web.WebSockets seems to have the same API as Microsoft.Web.WebSockets, but with classes and methods prefixed with AspNet.

System.ServiceModel.WebSockets is part of the WCF namespace, which also seems a sensible place to put this stuff.

Help - I'm confused. What should I be using?

Answers


I will add little bit more to your confusion. Microsoft.* prefixed assemblies / namespaces are usually either very specific to some language or not part of .NET framework (shipped out of band (or prototypes)).

Assemblies / namespaces shipped with .NET framework usually start with System.*. There are two namespaces containing features related to WebSockets in .NET 4.5:

  • System.Net.WebSockets - implementation of WebSockets
  • System.Web.WebSockets - integration of WebSockets with ASP.NET

I haven't see System.ServiceModel.WebSockets but I think there was some prototype named Microsoft.ServiceModel.WebSockets


html5labs.interoperabilitybridges.com:

...we don't plan any future updates to this prototype.

System.Web.WebSockets:

...namespace contains classes that support adding WebSocket functionality to ASP.NET Web Forms applications.

Microsoft.Web.WebSockets:

...provides functionality for writing WebSocket-enabled server applications on Windows 8 using ASP.NET and WCF


My conclusion:

  • System.Net.WebSockets seems like something low-level.
  • System.Web.WebSockets need when you use ASP.NET Web Forms
  • Microsoft.Web.WebSockets from NuGet looks like best choice when you use ASP.NET MVC

@Greg Woods re System.ServiceModel.WebSockets: you weren't imagining it.

http://html5labs.interoperabilitybridges.com/media/1165/readme.htm


As for the Microsoft.Web.WebSockets vs System.Web.WebSockets...

I think that:

System.Web.WebSockets- gives you a lower api for working with websockets

while...

Microsoft.Web.WebSockets- is kind of a higher api, which makes it far more easy to deal with, and also tries to mirroring the events/functions that are in the html5/javascript specification (e.g.- onerror,onopen, onmessage,onclose, send, etc...)


This is my belief on why the naming Microsoft.Web.WebSockets:

"This preview package provides functionality for writing WebSocket-enabled server applications on Windows 8 using ASP.NET and WCF. Requires .NET 4.5 RC and Windows 8 RC."

It's probably a Microsoft.* named library because it was developed against Windows 8 RC. Which isn't a solid dependency so it can't be part of the official .net framework.

Of course once Windows 8 comes out they can depend on it and start releasing websockets libraries as part of the official framework. So the Microsoft.Web.WebSockets may be effectively obsoleted without ever leaving prerelease status.

What about System.Web.WebSockets vs System.Net.WebSockets?

System.Web.WebSockets: "classes that support adding WebSocket functionality to ASP.NET Web Forms applications."

Hm... Seems simple. These classes are designed to be used from ASP.NET Web Forms. Do they require Windows 8? Not sure.

System.Net.WebSockets: is something else that isn't tied to Web Forms. But it only works if you have Windows 8.

Microsoft.ServiceModel.WebSockets

Another old prerelease package. This one works on Windows 7!

Note: instead of worrying about what works on what platform+framework to use to get WebSockets kinda goes away you could just use SignalR instead, which will pick a transport and try to do something like websockets for you.


Need Your Help

How can I add ON DELETE constraint on the table?

mysql sql

How can I add ON DELETE constraint on the table?