Skip to content
Jim Cowart edited this page Jan 16, 2013 · 1 revision

The postal.fedx.onFederatedMsg( data ) method is invoked by postal.federation transport plugins (for example, postal.xframe). When a transport plugin receives a message from a remote instance, assuming it's a valid postal.federation message and all other checks pass, the packingSlip from the message is attached to an object literal argument, along with a property holding the name of the transport plugin, as well as the source 'client proxy' instance (usually an instance derived from FederationClient). Because a transport plugin's client proxy instance derives from FederationClient, it will be using the FederationClient.prototype.onMessage method, which looks like this:

FederationClient.prototype.onMessage = function ( packingSlip ) {
	if ( this.shouldProcess() ) {
		postal.fedx.onFederatedMsg( {
			transport : this.transportName,
			packingSlip : packingSlip,
			source : this
		} );
	}
};

So, onFederatedMsg receives this object as its argument, and then:

  • If the local instance of postal is ready (meaning - it has a postal.instanceId() value), the it looks up a handler for the packingSlip type (ping, pong, bundle or message), and if one is found, it invokes it, passing the object argument to the handler.
  • If the local instance of postal is not ready, the argument gets queued up in the _inboundQueue, and will be replayed once the local instance of postal has an instanceId.
  • If a packling slip of any type not handle by postal.federation is received, an exception is thrown (since the assumption is you might be using an out of date version of postal.federation in one of your windows).

Clone this wiki locally