Specific Protocol Features

In MonaServer we have taken the choice to give a powerfull generic access to protocols. For this reason we take importance to the choice of protocols implemented in order to fit well with our architecture.

This page treat the specificities of each protocol implemented by MonaServer.


API specificities

onConnection returned array

Parameters can be sended to the client on connection by returning them in an associative array. Here is an example :

function onConnection(client,...)
  return {message="welcome",id=1}

onConnection parameters

As it is said in the API first parameter of onConnection is the Client object.

Others ar AMF parameters given to NetConnection:connect(address:String, … parameters) converted in LUA types (see AMF to LUA conversions to know how AMF/LUA conversion works).


In RTMP & RTMFP protocols the client properties are URL query parameters and standard informations given by flash client at connection.

Here is a list of known static flash client parameters :

  • swfUrl (read-only), URL of the SWF file which has gotten the connection.
  • tcUrl (read-only), RTMPF/RTMFP URL used to connect to this session.
  • pageUrl (read-only), URL of the page which has gotten the connection, it means the URL of the page which contains the SWF client.
  • flashVer (read-only), flash version of the client.
  • app (read-only), The Server application name the client is connected to.
  • fpad (read-only), True if proxy is being used.
  • audioCodecs (read-only), Indicates what audio codecs are supported.
  • videoCodecs (read-only), Indicates what video codecs are supported.
  • objectEnconding (read-only), AMF encoding method.
  • capabilities (read-only),
  • videoFunction (read-only), the SUPPORT_VID_CLIENT_SEEK constant.

And here is a sample of RTMFP URL query parameters sended by a flash client :


HTTP & WebSocket

API specificities

onConnection returned array

Some specific parameters can be set returning an associative array like this :

function onConnection(client,...)
  return {index="index.html", timeout=7}

HTTP specific parameters :

  • index, true by default. If true the Server will send a view of the application’s directory, otherwise return a 404 error file. If it is a string MonaServer will try to return the corresponding file in the application’s directory.

onConnection parameters

As it is said in the API first parameter of onConnection is the Client object.

The following parameter is an array which contains URL query parameters from the HTTP request.

  -- show each parameters from url
function onConnection(client, parameters)


With HTTP protocol the client properties maps cookies sended by client and some connection properties :

  • HTTPVersion (read-only), the version of HTTP used.

client.properties(key, value[,{ options }])

As client.properties maps cookies values you can also set cookies by using the client.properties() method. Parameter are :

  • key , the key name of the cookie.
  • value , the value corresponding to key.
  • and an optional object containing the following options :
    • expires=<time> (optional), 0 by default, an integer value that represents the number of seconds (since now) that the client should keep the cookie,
    • path=”<value>” (optional), the server path on which the cookie applies,
    • domain=”<value>” (optional), the domain on which the cookie should be send,
    • secure=<bool> (optional), true if the cookie should be send only on a securised connection,
    • httponly=<bool> (optional), true if the cookie should be visible only by the HTTP protocol,

The returned value is the value parameter if the operation succeed, otherwise it returns nil.

Here is an example of a cookie named test with a value of value1 that should be sended by client for the 5 next minutes on each application (“/”) only for HTTP requests to the host :

INFO("Result : ", client.properties("test", "value1", {expires=300, path="/", domain="", secure=false, httpOnly=true}))


To unset a cookie on the client side you can set a negative value to the expires parameter.