Ejemplo n.º 1
0
 // Invoke the ReceivedMessage event
 protected virtual void OnReceivedMessage(StompMessageEventArgs e)
 {
     if (ReceivedMessage != null)
     {
         ReceivedMessage(this, e);
     }
 }
Ejemplo n.º 2
0
        void stompListener_ReceivedMessage(object sender, StompMessageEventArgs e)
        {
            Hashtable data = (Hashtable)Json.JsonDecode(e.Message.Body);

            if (data != null)
            {
                string type = null;

                if (data.ContainsKey("Type"))
                {
                    type = data["Type"].ToString();
                }

                if (type == "TEDDI" || (type == null && data.ContainsKey("Humidity")))  // Appears to be TEDDI type
                {
                    Packet packet = Packet.PacketFromStomp(data);
                    if (packet != null)
                    {
                        TeddiPacketReceived(packet);
                    }
                }
                else if (type == "TEDDI_Status")            // Appears to be TEDDI_Status type
                {
                    StatusPacket statusPacket = StatusPacket.StatusPacketFromStomp(data);
                    if (statusPacket != null)
                    {
                        TeddiStatusPacketReceived(statusPacket);
                    }
                }
                else if (type == null)
                {
                    string debug = e.Message.Body;
                    if (debug.Length > 128)
                    {
                        debug = debug.Substring(0, 128) + "...";
                    }
                    Console.WriteLine("WARNING: Un-typed JSON STOMP message: " + debug + "");
                }
                else
                {
                    Console.WriteLine("WARNING: Unknown STOMP type: " + type + "");
                }
            }
            else
            {
                string debug = e.Message.Body;
                if (debug.Length > 128)
                {
                    debug = debug.Substring(0, 128) + "...";
                }
                Console.WriteLine("WARNING: Couldn't parse JSON: " + debug + "");
            }
        }
Ejemplo n.º 3
0
 // Invoke the ReceivedMessage event
 protected virtual void OnReceivedMessage(StompMessageEventArgs e)
 {
     if (ReceivedMessage != null) { ReceivedMessage(this, e); }
 }
Ejemplo n.º 4
0
        void stompListener_ReceivedMessage(object sender, StompMessageEventArgs e)
        {
            Hashtable data = (Hashtable)Json.JsonDecode(e.Message.Body);
            if (data != null)
            {
                string type = null;

                if (data.ContainsKey("Type")) { type = data["Type"].ToString(); }

                if (type == "TEDDI" || (type == null && data.ContainsKey("Humidity")))  // Appears to be TEDDI type
                {
                    Packet packet = Packet.PacketFromStomp(data);
                    if (packet != null)
                    {
                        TeddiPacketReceived(packet);
                    }
                }
                else if (type == "TEDDI_Status")            // Appears to be TEDDI_Status type
                {
                    StatusPacket statusPacket = StatusPacket.StatusPacketFromStomp(data);
                    if (statusPacket != null)
                    {
                        TeddiStatusPacketReceived(statusPacket);
                    }
                }
                else if (type == null)
                {
                    string debug = e.Message.Body;
                    if (debug.Length > 128) { debug = debug.Substring(0, 128) + "..."; }
                    Console.WriteLine("WARNING: Un-typed JSON STOMP message: " + debug + "");
                }
                else
                {
                    Console.WriteLine("WARNING: Unknown STOMP type: " + type + "");
                }
            }
            else
            {
                string debug = e.Message.Body;
                if (debug.Length > 128) { debug = debug.Substring(0, 128) + "..."; }
                Console.WriteLine("WARNING: Couldn't parse JSON: " + debug + "");
            }
        }