Child pages
  • OpenFire
Skip to end of metadata
Go to start of metadata

Unified presence

XML-RPC presence java clients provided by sipxecs (sipXopenfire project) can be used using the SHARED_SECRET
NOTE: Calls are secured using BASIC Authentication
Example using curl CLI tool to get presence information

Get presence information

Method name: getUnifiedPresenceInfo
Description: This method returns XMPP information being given the sip extension, as described below.
Step 1. Create a file called get-presence.xml with content, replace 200 with the SIP user ID you wish to get presence information on:
<methodCall>
<methodName>presenceServer.getUnifiedPresenceInfo</methodName>
<params>
<param>
<value>
<string>2011</string>
</value>
</param>
</params>
</methodCall>
Step 2. Then run this command, replacing mypbx.example.com with the FQDN of your sipXecs system:
curl {color}
-H "Content-Type: application/xml" {color}
-X POST {color}
--data-binary @get-presence.xml {color}
http://<user>:<password>@mypbx.example.com:9094/plugins/sipx-openfire-presence/status

Response example:
<methodResponse xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions">
<params>
<param>
<value>
<struct>
<member>
<name>custom-presence-message</name>
<value></value>
</member>
<member>
<name>sip-id</name>
<value>2011</value>
</member>
<member>
<name>status-code</name>
<value>ok</value>
</member>
<member>
<name>unified-presence</name>
<value>available-for-both</value>
</member>
<member>
<name>jabber-id</name>
<value>mirceac@openuc.ezuce.com</value>
</member>
<member>
<name>xmpp-presence</name>
<value>AVAILABLE</value>
</member>
<member>
<name>sip-presence</name>
<value>IDLE</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>

Get XMPPU user name

Method name: getXMPPUsername
Description: This method returns the xmpp username being given the email address saved in user-portal: contact information page.

XML Request

<methodCall>
<methodName>presenceServer.getXmppUsername</methodName>
<params>
<param>
<value>
<string>mirceac@ezuce.com</string>
</value>
</param>
</params>
</methodCall>

Response

<methodResponse xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions">
<params>
<param>
<value>
<struct>
<member>
<name>sip-id</name>
<value>mirceac</value>
</member>
<member>
<name>status-code</name>
<value>ok</value>
</member>
</struct>
</value>
</param>
</params>


Get presence state

Method name: getPresenceState
Description: This method returns the presence state being given the XMPP ID. The string representation of the presence might be: AVAILABLE, AWAY, BUSY, OFFLINE, CHAT, EXTENDED_AWAY.

XML Request

<methodCall>
<methodName>presenceServer.getPresenceState</methodName>
<params>
<param>
<value>
<string>mirceac</string>
</value>
</param>
</params>

Response

<methodResponse xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions">
<params>
<param>
<value>
<struct>
<member>
<name>status-code</name>
<value>ok</value>
</member>
<member>
<name>xmpp-presence</name>
<value>AVAILABLE</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>
</methodCall>


Set presence state

Method name: setPresenceState
Description: This method changes the presence state of the given XMPP user id The xmppPresenceAsString parameter can have the following String representations: AVAILABLE, AWAY, BUSY, OFFLINE, CHAT, EXTENDED_AWAY.

XML Request

? (String xmppUsername, String xmppPresenceAsString)?
XML to send:
<methodCall>
<methodName>presenceServer.setPresenceState</methodName>
<params>
<param>
<value>
<string>mirceac</string>
</value>
</param>
<param>
<value>
<string>AWAY</string>
</value>
</param>
</params>
</methodCall>

Response

? (String xmppUsername, String xmppPresenceAsString)?
XML to send:
<methodCall>
<methodName>presenceServer.setPresenceState</methodName>
<params>
<param>
<value>
<string>mirceac</string>
</value>
</param>
<param>
<value>
<string>AWAY</string>
</value>
</param>
</params>
</methodCall>


If you now call the getPresenceState method it will show you AWAY as xmpp-presence value

Set presence status

Method name: setPresenceStatus
Description: This method sets the given status message of the given XMPP user ID.
(String id, String status)

XML Request

<methodCall>
<methodName>presenceServer.setPresenceStatus</methodName>
<params>
<param>
<value>
<string>mirceac</string>
</value>
</param>
<param>
<value>
<string>Here</string>
</value>
</param>
</params>
</methodCall>

Response

<methodResponse xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions">
<params>
<param>
<value>
<struct>
<member>
<name>status-code</name>
<value>ok</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>



Get presence status

Method name: getPresenceStatus
Description: This method returns the presence status message of the given XMPP user ID.
public Map getPresenceStatus(String id)

XML Request

<methodCall>
<methodName>presenceServer.getPresenceStatus</methodName>
<params>
<param>
<value>
<string>mirceac</string>
</value>
</param>
</params>
</methodCall>

Response

<methodResponse xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions">
<params>
<param>
<value>
<struct>
<member>
<name>custom-presence-message</name>
<value>Here</value>
</member>
<member>
<name>status-code</name>
<value>ok</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>


Ping

Method name: setPresenceState
Description: This method verifies if the XMPP server is running.
(String originatorName)

XML Request

<methodCall>
<methodName>presenceServer.ping</methodName>
<params>
<param>
<value>
<string>mirceac</string>
</value>
</param>
</params>
</methodCall>

Response

<methodResponse xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions">
<params>
<param>
<value>
<struct>
<member>
<name>status-code</name>
<value>ok</value>
</member>
<member>
<name>instance-handle</name>
<value>of:821711375117195347</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>


Register presence monitor

Method name: registerPresenceMonitor
Description: This method registers a listener to be notified when the presence changes.
(String protocol, String serverUrl )

XML Request

? (String xmppUsername, String xmppPresenceAsString)?
XML to send:
<methodCall>
<methodName>presenceServer.setPresenceState</methodName>
<params>
<param>
<value>
<string>mirceac</string>
</value>
</param>
<param>
<value>
<string>AWAY</string>
</value>
</param>
</params>
</methodCall>

Response

? (String xmppUsername, String xmppPresenceAsString)?
XML to send:
<methodCall>
<methodName>presenceServer.setPresenceState</methodName>
<params>
<param>
<value>
<string>mirceac</string>
</value>
</param>
<param>
<value>
<string>AWAY</string>
</value>
</param>
</params>
</methodCall>

  • No labels