Changes in WebSockets API

May 8, 2015 1:27 pm Published by Leave your thoughts

Starting from the build 2.0.3161.3 we have changed and improved the existing Web Sockets APIs! The new API is described in updated documentation here: https://github.com/Starcounter/Starcounter/wiki/Using-websockets
The following major changes can be noted:

  1. There is no more “CargoId”. Instead, one should call WebSocket.ToUInt64() to get the unique WebSocket identifier. Having this identifier, user can later “reconstruct” the WebSocket object by calling its constructor: WebSocket ws = new WebSocket(id), which, in turn, can be used to call Send and Disconnect.

  2. ForEach procedures are also gone! Now to send on any WebSocket you just need to have your thread attached to Starcounter scheduler.

Here is the example of a small application that uses WebSockets: https://github.com/Starcounter/Starcounter/blob/develop/src/Samples/WebSocketsTest/Server/SimpleBroadcaster.cs

Good luck!

Categorised in:

This post was written by Alexey Moiseenko

Leave a Reply

Your email address will not be published. Required fields are marked *