protected void Init(System.Net.CookieContainer cookies = null, Dictionary <string, string> requestHeader = null) { //if (this.webSocket == null) { Address = ReBuildAddress(Address); webSocket = new WebSocketClient(Address); webSocket.Socket.Options.Cookies = cookies; if (requestHeader != null) { foreach (KeyValuePair <string, string> item in requestHeader) { webSocket.Socket.Options.SetRequestHeader(item.Key, item.Value); } } webSocket.ConnectionOpened += WebSocketOnOpen; webSocket.MessageReceived += WebSocketOnMessage; webSocket.ConnectionClosed += WebSocketOnClosed; webSocket.Error += WebSocketOnError; if (AutoPing) { Task.Run(() => { while (true) { Timer_Elapsed(null, null); Thread.Sleep(3000); } }); //this.timer = new System.Timers.Timer(this.PingInterval); //this.timer.Elapsed += Timer_Elapsed; webSocket.ConnectionClosed += delegate { DisablePing(); }; } } }
protected abstract void OnReceiveMessage(WebSocketClient webSocket, MessageEventArgs e);
protected abstract void StompConnect(WebSocketClient webSocket);
protected abstract void Ping(WebSocketClient webSocket);
protected abstract void SubscribeTopic(WebSocketClient webSocket, string data);