Пример #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);
        }
Пример #2
0
 public void OnWebsocketMessage(object sender, MessageEventArgs args)
 {
     config.onMessageCallback(this, args.Data);
 }