Esempio n. 1
0
        public IWebsocket Build(WebsocketConfiguration config)
        {
            var websocket = new WebSocket(config.uri);

            websocket.InternalRequest.ConnectTimeout = TimeSpan.FromSeconds(8);

            var adapter = new BestHTTPWebsocketAdapter(websocket);

            websocket.OnOpen    += (_) => config.onOpenCallback(adapter);
            websocket.OnClosed  += (_, code, message) => config.onCloseCallback(adapter, code, message);
            websocket.OnError   += (_, message) => config.onErrorCallback(adapter, message);
            websocket.OnMessage += (_, msg) => config.onMessageCallback(adapter, msg);

            return(adapter);
        }
Esempio n. 2
0
 public void OnWebsocketError(object sender, ErrorEventArgs args)
 {
     config.onErrorCallback(this, args.Message);
 }