Esempio n. 1
0
        // private routines
        private void SendHeartBeat(AsyncSkt SocketToSendOn)
        {
            //disable the heartbeat so we don't get queued events
            DisableHeartbeat(); // _heartbeatTimer.Enabled = false;
            SocketCommand myHeartBeat = new SocketCommand()
            {
                ID        = TcpIpCommon.GetMyID(),
                Timestamp = DateTime.Now,
                //Command = CommandType.Heartbeat
            };

            //LogAccess.WriteLog("...heartbeat...", "Talker");
            SendData(myHeartBeat, SocketToSendOn);
            //re enable the timer so we can send future heartbeats
            EnableHeartbeat(); // _heartbeatTimer.Enabled = true;
        }
Esempio n. 2
0
        public bool Talk(SocketCommand CommandToSend)
        {
            //disable the heartbeat so we don't get a heartbeat while trying to send a command
            DisableHeartbeat(); // _heartbeatTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
            // update ID, timestamp
            CommandToSend.ID        = TcpIpCommon.GetMyID();
            CommandToSend.Timestamp = DateTime.Now;

            try
            {
                SendData(CommandToSend, _socketTalker);
                return(true);
            }
            catch (Exception ex)
            {
                //LogAccess.WriteLog(ex.ToString(), "Talker");
                return(false);
            }
            finally
            {
                //re enable the timer so we can send future heartbeats
                EnableHeartbeat(); // _heartbeatTimer.Change(_heartbeatInterval,_heartbeatInterval);
            }
        }