Ejemplo n.º 1
0
        private void _heartbeat_Elapsed(object sender, ElapsedEventArgs e)
        {
            HeartbeatMessage heartbeat = HeartbeatMessage.Parse(_serviceInfo);

            _conn.Publish("MOL.HEARTBEAT", Encoding.Default.GetBytes(heartbeat.ToString()));
        }
Ejemplo n.º 2
0
        private void _heartbeat_Elapsed(object sender, ElapsedEventArgs e)
        {
            HeartbeatMessage heartbeat = HeartbeatMessage.Parse(_serviceInfo);

            _transporter.Publish("MOL.HEARTBEAT", heartbeat);
        }
Ejemplo n.º 3
0
        public static WsjtxMessage Parse(byte[] datagram)
        {
            if (!CheckMagicNumber(datagram))
            {
                return(null);
            }

            int cur = MAGIC_NUMBER_LENGTH;

            int schemaVersion = DecodeQInt32(datagram, ref cur);
            var messageType   = (MessageType)DecodeQInt32(datagram, ref cur);

            try
            {
                if (schemaVersion == 2 || schemaVersion == 3)
                {
                    WsjtxMessage result;

                    if (messageType == MessageType.HEARTBEAT_MESSAGE_TYPE)
                    {
                        result = HeartbeatMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.STATUS_MESSAGE_TYPE)
                    {
                        result = StatusMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.DECODE_MESSAGE_TYPE)
                    {
                        result = DecodeMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.ENQUEUE_DECODE_MESSAGE_TYPE)
                    {
                        result = EnqueueDecodeMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.CLEAR_MESSAGE_TYPE)
                    {
                        result = ClearMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.QSO_LOGGED_MESSAGE_TYPE)
                    {
                        result = QsoLoggedMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.CLOSE_MESSAGE_TYPE)
                    {
                        result = CloseMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.WSPR_DECODE_MESSAGE_TYPE)
                    {
                        result = WsprDecodeMessage.Parse(datagram);
                    }
                    else if (messageType == MessageType.LOGGED_ADIF_MESSAGE_TYPE)
                    {
                        result = LoggedAdifMessage.Parse(datagram);
                    }
                    else
                    {
                        result = new UnknownMessage();
                    }
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new ParseFailureException(messageType, datagram, ex);
            }

            throw new NotImplementedException($"Schema version {schemaVersion}, message type {messageType}");
        }