What is Megaphone?

What is Megaphone?
The Megaphone project is about enhancing open source chat software. Specifically, the goal is to allow ejabberd to support 1,000,000 simultaneous users. See The Plan page for more details on how I plan to solve this problem. See the About this Blog page for more details on why I created this blog.

Wednesday, March 21, 2012

End of the Endless Loop

Previously...
  • I modified megaphone to send packets.
  • I noted that data was not getting delivered to ECM.
  • I solved the undelivered data problem and added heartbeats.

It turned out the endless loop on the ECM side was a relatively simple problem.  Here is the method that was receiving the packets:


    me.processDataFromServer = function (data)
    {
console.log("processDataFromServer: " + data);
        //
        // check for a complete packet before adding additional data.  This is not 
        // supposed to happen, but check anyway
        //
        if (me.packet && me.packet.complete)
        {
            me.processPacket();
        }

        if (null == me.packet)
        {
            me.packet = new Packet(data);
        }
        else
        {
            me.packet.add(data);
        }

        while (me.packet && me.packet.complete)
        {
            var leftovers = me.packet.leftovers;

            me.processPacket();

            if (leftovers)
            {
                me.packet = new Packet(leftovers);
            }
        }
    };

The problem was that processPacket was supposed to set "me.packet" to null, but in the case of a heartbeat packet, it was not doing this.  Once that was resolved, the endless loop well...ended.  

At this point, it seems like data is being received by ECM, but Pidgin never sends a reply to the reply from ejabberd.

For next time: is ECM really receiving a reply?

No comments:

Post a Comment