actionscript-3netconnection

Responder callback methods


I need to create a Responder object, the constructor documentation says:

Parameters

result:Function — The function invoked if the call to the server succeeds and returns a result.

status:Function (default = null) — The function invoked if the server returns an error.

What is the parameter of the status function? it says the signature is function(default = null), but it doesn't actually explain what is default.


Solution

  • Here function(default = null) means that the default value for the second parameter is null rather than the signature if the status handler.

    As for the signature of the status handler it depends on your client<->server protocol. For example look at the MessageResponder class that inherits the Responder that are used in the flex remoting. It has the strongly typing serialization of AMF directly to the IMessage:

    public function MessageResponder(agent:MessageAgent, message:IMessage,
                                                        channel:Channel = null)
    {
        super(result, status);
    
        ...      
    }
    ...
    final public function result(message:IMessage):void {...}
    final public function status(message:IMessage):void {...}
    

    In general you can pass the functions with the single Object argument:

    public function status(message:Object):void {}
    public function result(message:Object):void {}