Name

NetConnection.addHeader( ) Method

Synopsis

                     myNetConnectionObject.addHeader(name, mustUnderstand, object)

Arguments

name

An arbitrary header name that can be recognized by the server.

mustUnderstand

A Boolean value that denotes whether the server must process the header before sending a result back to the Flash application.

object

Any ActionScript object that becomes the header named in the addHeader( ) call.

Description

The addHeader( ) method is useful when you have a specific header that requires server processing, or an arbitrary piece of information that you want attached to every AMF packet, such as a user identification number or session ID.

After using addHeader( ), each subsequent AMF packet from the client will contain the header information. AMF calls returned from the server do not include this header, unless your server-side code processes the header and manually adds it to the return packet.

Example

The following code shows the basic syntax of the addHeader( ) method:

if (connected == null) {
  connected = true;
  NetServices.setDefaultGatewayUrl("http://127.0.0.1/flashservices/gateway");
  var my_conn = NetServices.createGatewayConnection( );
  var my_header = {user:'tom', password:'muck'};
  my_conn.addHeader('myLogin', false, my_header);
}

In this case, a header named myLogin is added to all AMF packets originating from the client on this connection. The my_header variable contains an ActionScript object that acts as the body of the myLogin header. The server must have the necessary ...

Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.