diff options
author | Remko Tronçon <git@el-tramo.be> | 2013-09-20 20:33:15 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2013-09-21 06:41:34 (GMT) |
commit | f3f717d09fddbcefeac03e5c99a42be43a1551be (patch) | |
tree | 7e689dd2495eefe84f1dde57f94b272a0bcbb9d5 /Sluift | |
parent | 33f9dc5337f1a59932b7ac117b0dea56e1dafe1a (diff) | |
download | swift-f3f717d09fddbcefeac03e5c99a42be43a1551be.zip swift-f3f717d09fddbcefeac03e5c99a42be43a1551be.tar.bz2 |
Sluift: Update documentation
Change-Id: I4b3450d166048db52ca4f531277799bb16996385
Diffstat (limited to 'Sluift')
-rw-r--r-- | Sluift/README | 2 | ||||
-rw-r--r-- | Sluift/README.md | 31 |
2 files changed, 31 insertions, 2 deletions
diff --git a/Sluift/README b/Sluift/README deleted file mode 100644 index 65fb648..0000000 --- a/Sluift/README +++ /dev/null @@ -1,2 +0,0 @@ -For example scripts, see the 'login.lua' script and the scripts in -Swiften/QA/ScriptedTests. diff --git a/Sluift/README.md b/Sluift/README.md index 8eacc2b..ae43846 100644 --- a/Sluift/README.md +++ b/Sluift/README.md @@ -19,3 +19,34 @@ In order to use the Sluift Lua module, make sure it is copied to a location in t Lua search path (`LUA_PATH`, or the built-in path). On Linux and Mac OS X, this is typically `<LUA_INSTALLPREFIX>/lib/lua/<LUA_VERSION>/`. If `require 'sluift'` fails, the error message will give an indication what this path is. + + +## Examples + +Example scripts can be found in `Examples/`, and in the Swift tree under +`Swiften/QA/ScriptedTests`. + +## Extending + +### Adding support for payloads + +To add support for a specific Swiften payload, create a new `LuaElementConvertor` +in `ElementConvertors/` by inheriting from `GenericLuaElementConvertor`, and register +it it `LuaElementConvertors.cpp`. The name of the convertor passed in the constructor +of `GenericLuaElementConvertor` should correspond to the snake case version of the +Swiften element it converts. For examples, see the existing convertors in +`ElementConvertors/`. + +When the convertor is registered, you can use it in message bodies, or in get/set +queries. For example, for the `command` convertor: + + client:set{to = 'alice@wonderland.lit', query = {_type = 'command', + type = 'execute', node = 'uptime'}} + +Optionally, you can add a convenience `set_<type>` shortcut on the client object by +adding it to the list of `get_set_shortcuts` in `boot.lua`. With such a shortcut, the +command above can be rewritten as: + + client:set_command{to = 'alice@wonderland.lit', command = { + type = 'execute', node = 'uptime'}} + |