Skip to content

Latest commit

 

History

History
 
 

joap

Jabber Object Access Protocol

A strophe plugin for the Jabber Object Access Protocol (XEP-0075).

Usage

Link the rpc, jid and the joap plugin below the strophe library in your HTML head section:

<head>
<!-- ... -->
<script type="text/javascript" src="strophe.min.js"></script>
<script type="text/javascript" src="jid.js"></script>
<script type="text/javascript" src="strophe.disco.js"></script>
<script type="text/javascript" src="strophe.rpc.js"></script>
<script type="text/javascript" src="strophe.joap.js"></script>
<!-- ... -->
</head>

After your client is sucessfully connected you can create, read, update and delete objects.

Server

objectServer = new connection.joap.JOAPServer "component.example.org"

# requesting the server description
objectServer.describe (iq, err, parsedDescription) ->

# requesting a class description
objectServer.describe "User", (iq, err, parsedDescription) ->

# creating a new instance
objectServer.add "User", { name:"My Name", age: 99 }, (iq, err, instanceAddress) ->

# reading an instance
objectServer.read "User", "instanceId", (iq, err, parsedResult) ->

# reading only a few properties of an instance
objectServer.read "User", "instanceId", ["email", "age"], (iq, err, parsedResult) ->

# modifying properties of an instance
objectServer.edit "User", "instanceId", { age: 27 }, (iq, err) ->

# deleting an instance
objectServer.delete "User", "instanceId", (iq, err) ->

# searching for instances
objectServer.search "User", {age: 60} , (iq, err, arrayOfInstanceIDs) ->

# searching and reading in one step
objectServer.searchAndRead "User", {type: "admin"}, ["email"], (iq, err, arrayOfInstancObjects) ->

# performing a method call
objectServer.methodCall "myMethod", "User", ["param1","param2"], (iq, err, result) ->

Class

aClass = new connection.joap.JOAPClass "[email protected]"

# requesting a class description
aClass.describe (iq, err, parsedDescription) ->

# searching for class instances
aClass.search (iq, err, arrayOfInstanceIDs) ->

# searching and reading
aClass.searchAndRead filter, limits, (iq, err, arrayOfInstances) ->

# creating a new instance
aClass.add { aProperty:"aValue" }, (iq, err, instanceAddress) ->

# subscribe to attribute changes of all instances
aClass.subscribe successHandler, changeHandler, {bare:true}

Object

obj = new connection.joap.JOAPObject "[email protected]/instanceId"

# modifying properties
obj.edit { key: 'value' }, (iq, err) ->

# subscribe to attribute changes of this instance
aClass.subscribe successHandler, changeHandler, {bare:true}

Dependencies

Available JOAP server implementations

Run tests

npm i && npm test