Skip to content
cumulusdev edited this page Jan 13, 2012 · 62 revisions

CumulusServer includes a powerfull script-engine (using LUA langage) to create your own server applications. It allows to extend Cumulus behavior to add your specific needs in a flexible scripting-way.

Generality

On start, Cumulus creates a www folder in its root directory if it doesn't exist already. In this space, you can create subfolders, each one of them describes one server application. When a client connects to CumulusServer, the URL path relates the application to use. For example, the address rtmfp://host:port/myApplication search its corresponding application in [CumulusRoot]/www/myService folder. First time CumulusServer builds and executes the file main.lua presents in this folder. Then, on new comer, the application already built is executed, unless main.lua file has been modified since the last time. Indeed when you edit main.lua file, the corresponding application is rebuilt in a dynamic way (without having to restart the server).

rtmfp://host:port/                   ->     [CumulusRoot]/www/main.lua (root application)
rtmfp://host:port/myApplication      ->     [CumulusRoot]/www/myApplication/main.lua
rtmfp://host:port/Games/myGame       ->     [CumulusRoot]/www/Games/myGame/main.lua

Each application is identified by its path, which is exactly the path part of the RTMFP URL connection. In the example above, root application has an empty string for path, then the both others have respectively /myApplication and /Games/myGame for path values.

Cummunication between applications

One application can access (read or write) to a variable of one other application, and can call one function of one other application. But it goes much further than that, applications can be specialized, and inherit them, exactly like inheritance of classes.

Application inheritance

Principle is simple, /Games/myGame application extends /Games application, and so all functions and variables available in /Games/main.lua are available in /Games/myGame/main.lua.

	-- /Games script application
	test = "I am Games"
	-- /Games/myGame script application
	print(test) -- displays "I am Games"
	-- /Games script application
	test = "I am Games"
	-- /Games/myGame script application
	print(test) -- displays "I am Games"
	test = "I am myGame"
	print(test) -- displays "I am myGame"
	test = nil
	print(test) -- displays "I am Games"

Note The root

Clone this wiki locally