예제 #1
0
 public WebSocketServerTransmissionConnection(WebSocket webSocket, CancellationToken cancellationToken)
 {
     Id            = UniqueId.Generate();
     _log          = LogManager.GetLogger <WebSocketServerTransmissionConnection>(Id.ToString());
     _cancellation = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
     _webSocket    = webSocket;
     _writer       = new WebSocketServerTransmissionWriter(_webSocket, _cancellation.Token);
     _reader       = new WebSocketServerTransmissionReader(_webSocket, _cancellation.Token);
     Completion    = ProcessAsync().LogCompletion(_log);
 }
        public WebSocketServerTransmissionConnection(IWebSocketConnection websocket)
        {
            _log       = LogManager.GetLogger <WebSocketServerTransmissionConnection>(Id.ToString());
            _webSocket = websocket;
            _disconnectCompletion.Task.PropagateCompletionToPromise(_connectCompletion);

            _reader = new WebSocketServerTransmissionReader(Id, _webSocket, CancellationToken);
            _writer = new WebSocketServerTransmissionWriter(Id, _webSocket, CancellationToken);

            _webSocket.OnOpen  += OnOpened;
            _webSocket.OnClose += OnClosed;
            _webSocket.OnError += OnError;

            Completion.LogCompletion(_log);

            _log.Trace("Created");
        }