protected SocketBase(OpenSocket openSocket) { openSocket(out _nngSocket).ThrowIfError(); _sender = new SocketSendBehavior(_nngSocket); _receiver = new SocketReceiveBehavior(_nngSocket); _asyncSender = new SocketSendAsyncBehavior(_nngSocket); _asyncReceiver = new SocketReceiveAsyncBehavior(_nngSocket); Options = new SocketOptions(_nngSocket, _asyncSender.Options, _asyncReceiver.Options); }
public async Task HandleNewConnection(WebSocket ws) { int id = this.Counter; this.Counter++; OpenSocket osc = new OpenSocket(ws, this, id); if (!this.Connections.TryAdd(this.Counter++, osc)) { // Missing proper CancellationToken handling await osc.Socket.CloseAsync(WebSocketCloseStatus.InternalServerError, "Missmatch in ids", CancellationToken.None); } else { await osc.Dispatch(); } }