示例#1
0
 protected virtual void WebSocketOnMessage(object sender, MessageEventArgs e)
 {
     try
     {
         OnReceiveMessage(webSocket, e);
     }
     catch (Exception ex)
     {
         LogRecord.Error("StompWebSocketMaketClientBase", $"{Name} receive message error {ex}.");
     }
 }
示例#2
0
 protected virtual bool StompConnect()
 {
     try
     {
         StompConnect(webSocket);
         return(true);
     }
     catch (Exception ex)
     {
         LogRecord.Error("StompWebSocketMaketClientBase", $"{Name} subscribe symbols error {ex}.");
     }
     return(false);
 }
示例#3
0
        //private int pingInterval = 30000;
        //public int PingInterval
        //{
        //    get
        //    {
        //        return this.pingInterval;
        //    }
        //    set
        //    {
        //        this.pingInterval = value;
        //        if (this.timer != null)
        //            this.timer.Interval = value;
        //    }
        //}

        protected virtual bool SubscribeSymbols()
        {
            try
            {
                IEnumerable <string> topics = GetSubscribeTopics();
                if (topics != null && topics.Any())
                {
                    foreach (string t in topics)
                    {
                        LogRecord.Info("StompWebSocketMaketClientBase", $"{Name} begin subscribe {t}");
                        SubscribeTopic(webSocket, t);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                LogRecord.Error("StompWebSocketMaketClientBase", $"{Name} subscribe symbols error {ex}.");
            }
            return(false);
        }
示例#4
0
 protected virtual void WebSocketOnError(object sender, ErrorEventArgs e)
 {
     LogRecord.Error("StompWebSocketMaketClientBase", $"{Name} has error:{e.Exception}.");
 }
示例#5
0
 protected virtual void WebSocketOnClosed(object sender, CloseEventArgs e)
 {
     LogRecord.Error("StompWebSocketMaketClientBase", $"{Name} was closed.");
 }