communication socket by using websocket and webrtc data channel
coset ( COmmunication sockET ) is a communication library for client server applications using WebRTC DataChannels.
Note: Project is currently in an very early state of development and not yet published to npm.
WebRTC DataChannel connections are made by using internal websocket signaling server. So the client has to support normal websockets and also WebRTC DataChannels when you’re going to use this library.
npm install @coset/server --save
For WebRTC especially DataChannels an SSL encryption is enforced, so you’re going to need an https server. For usage examples have a look at the example directory.
server
restricted to https serverserver
-> client
-> server
) to WebSocket transport layerserver
-> client
-> server
) to RtcDataChannel transport layerdebug
[x] Encoding/Decoding of packages with registering serialization schemes and handler
arraybuffer
[x] Add attach of listener for packet type with included message structure ( first parameter type, second callback, 3rd message structure ) used for send and receive
/*
* handler will be used for encode of data
* before send and decode of data after receive
* before passing data out
*/
client.Serialize(
Message.Position, {
a: Type.Char,
b: Type.Int,
c: Type.Short,
d: Type.Float,
}
);
/*
* handler called after decode has been done
*/
client.Handler(
Message.Position,
( data ) => {
/* ... do something with data structure ... */
}
);
[x] Support (de-)serialization of data as common helper
Byte
: 1 byteUByte
: 1 byteShortInt
: 2 byteUShortInt
: 2 byteInt
: 4 bytesUInt
: 4 bytesFloat
: 4 bytesDouble
: 8 bytes