WebSocket Client implementation for C#.
ver 0.7.6
- async default.
- lightweight.
- thread free.
- task free.
- runnable on C# 3.5 or later(includes Unity).
var webuSocket = new WebuSocket(
"ws:https://somewhere:someport",
1024 * 100,// default buffer size.
() => {
// connected.
},
(Queue<ArraySegment<byte>> datas) => {
// data received.
while (0 < datas.Count) {
var data = datas.Dequeue();
var bytes = new byte[data.Count];
Buffer.BlockCopy(data.Array, data.Offset, bytes, 0, data.Count);
// use "bytes".
}
},
() => {
// pinged.
},
closeReason => {
// closed.
},
(errorReason, e) => {
// error happedned.
},
customHeaderKeyValues // Dictionary<string, string> which can send with connecting signal.
);
sample unity project is here
SampleProject
- basic WebSocket API
- connect by ipv4 & 6
- connect by domain
- tls
- reconnection
- disconnect detection by ping-pong timeout
- basic auth
- http redirection(necessary?)
- tls 1.3
- else...
contribution welcome!
see below.
LICENSE