Packageorg.restfulx.controllers
Classpublic class ServerPushController
InheritanceServerPushController Inheritance flash.events.EventDispatcher

This controller adds support for receiving messages from servers capable of pushing messages, e.g. Juggernaut.

First, install Juggernaut as described here: http://juggernaut.rubyforge.org/

Second, you need to set up ServerPushController


Example
You can initialize ServerPushController in your application like so
   private var c:ServerPushController;
      private function init():void {
     Rx.enableLogging();
     ApplicationController.initialize();
     c = new ServerPushController("localhost", 5001);
     c.addEventListener(ServerPushEvent.ID, onServerPush);
   }
      private function onServerPush(event:ServerPushEvent):void {
     trace("message:" + event.message);
   }
   
You can push plain-text messages, XML/JSON formatted messages or anything else that can be pushed with Juggernaut. If you are pushing XML/JSON you can then optionally unmarshall and cache your server pushed objects.

Unmarshalling messages from the server
   private function onServerPush(event:ServerPushEvent):void {
     var unmarshalled:RxModel = Rx.serializers.xml.unmarshall(event.message)
      as RxModel;
     Rx.models.cache.create(unmarshalled); 
   }
   
Lastly, you need to start the juggernaut server and push some messages to try this out.

Starting juggernaut server
      juggernaut -c config/juggernaut.yml
   
You can then navigate the app at http://localhost:3000 and push messages from the server or console.

Pushing messages
    Juggernaut.send_to_all("hello from the server")
   



Public Properties
 PropertyDefined by
  currentSignature : String
current message signature
ServerPushController
  lastMessageId : String
last message received from the server
ServerPushController
  opts : Object
options for configuring ServerPushController such as channels
ServerPushController
Public Methods
 MethodDefined by
  
ServerPushController(host:String, port:int, opts:Object = null)
Creates a new ServerPushController instance
ServerPushController
Property detail
currentSignatureproperty
public var currentSignature:String

current message signature

lastMessageIdproperty 
public var lastMessageId:String

last message received from the server

optsproperty 
public var opts:Object

options for configuring ServerPushController such as channels

Constructor detail
ServerPushController()constructor
public function ServerPushController(host:String, port:int, opts:Object = null)

Creates a new ServerPushController instance

Parameters
host:String — the host to connect to (e.g. localhost)
 
port:int — the port to connec to (e.g. 5001)
 
opts:Object (default = null) — options to use during configuration/handshake, such as channels to connect to