Exemplo n.º 1
0
        public WebsocketTransport(Uri brokerUrl, ITransportEventHandler handler, WebsocketTransportSettings settings)
        {
            _brokerUrl = brokerUrl;
            _handler   = handler;
            _socket    = new WebSocket(brokerUrl.ToString(),
                                       receiveBufferSize: settings.ReceiveBufferSize,
                                       customHeaderItems: settings.HttpHeaders
                                       .Select(_ => new KeyValuePair <string, string>(_.Key, _.Value.ToString()))
                                       .ToList()
                                       );
            _socket.Security.Certificates = settings.SslCertificates;

            _socket.Opened          += OnWsOpened;
            _socket.Closed          += OnWsClosed;
            _socket.Error           += OnWsError;
            _socket.MessageReceived += OnWsMessageReceived;
            _socket.DataReceived    += DataReceived;
        }
 public ITransport Create(Uri brokerUrl, ITransportEventHandler handler)
 {
     return(new WebsocketTransport(brokerUrl, handler, _websocketSettings));
 }