org.spicefactory.cinnamon.io.netconnection
Class NetConnectionIoHandler

java.lang.Object
  extended by org.spicefactory.cinnamon.io.netconnection.NetConnectionIoHandler
All Implemented Interfaces:
IoHandler

public class NetConnectionIoHandler
extends Object
implements IoHandler

Cinnamons default IoHandler implementation that should be used in conjunction with the client-side NetConnectionServiceChannel. The AS3 NetConnection class may wrap multiple requests in a single "envelope" and this implementation knows how to decode that envelope before decoding the AMF3 payloads of the request.

Author:
Jens Halm

Field Summary
static String ERROR_CALLBACK
           
static String RESULT_CALLBACK
           
 
Constructor Summary
NetConnectionIoHandler()
           
 
Method Summary
 Envelope createResponseEnvelope(Envelope requestEnvelope)
          Creates a new Envelope to be used for the response sent to the client
 MessageHolder createResponseMessage(MessageHolder requestMessage, Object message, boolean isError)
          Creates a new response messages for the specified request message and result object.
 Envelope decodeAMF(AMFInput input)
          Reads and returns the AMF envelope containing all AMF request messages from the specified input.
 void encodeAMF(AMFOutput output, Envelope envelope)
          Encodes and writes the specified envelope containing all response messages to the output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESULT_CALLBACK

public static final String RESULT_CALLBACK
See Also:
Constant Field Values

ERROR_CALLBACK

public static final String ERROR_CALLBACK
See Also:
Constant Field Values
Constructor Detail

NetConnectionIoHandler

public NetConnectionIoHandler()
Method Detail

decodeAMF

public Envelope decodeAMF(AMFInput input)
Description copied from interface: IoHandler
Reads and returns the AMF envelope containing all AMF request messages from the specified input.

Specified by:
decodeAMF in interface IoHandler
Parameters:
input - the AMF input to read from
Returns:
the AMF envelope containing all AMF request messages

encodeAMF

public void encodeAMF(AMFOutput output,
                      Envelope envelope)
Description copied from interface: IoHandler
Encodes and writes the specified envelope containing all response messages to the output.

Specified by:
encodeAMF in interface IoHandler
Parameters:
output - the AMF output to write to
envelope - the envelope containing all AMF response messages

createResponseEnvelope

public Envelope createResponseEnvelope(Envelope requestEnvelope)
Description copied from interface: IoHandler
Creates a new Envelope to be used for the response sent to the client

Specified by:
createResponseEnvelope in interface IoHandler
Parameters:
requestEnvelope - the corresponding request envelope
Returns:
a new Envelope to be used for the response sent to the client

createResponseMessage

public MessageHolder createResponseMessage(MessageHolder requestMessage,
                                           Object message,
                                           boolean isError)
Description copied from interface: IoHandler
Creates a new response messages for the specified request message and result object.

Specified by:
createResponseMessage in interface IoHandler
Parameters:
requestMessage - the request message that was processed
message - the message to sent as a response
isError - whether the response message represents an error
Returns:
a new response messages for the specified request message and result object