Using the GatewayHelper object

The CFML GetGatewayHelper function returns a GatewayHelper object with several methods that manage your gateway and buddy list. The GatewayHelper methods let you do the following:

  • Get and set gateway configuration information and get gateway statistics.
  • Get and set the gateway online status.
  • Manage the gateway's buddy list
  • Manage permissions for others to get information about the gateway status.
    The following sections briefly describe the class methods. For detailed information about each method, see IM Gateway GatewayHelper class methods in the CFML Reference.

Gateway configuration information and statistics methods

The following table describes the methods that you can use to get and set configuration information and get gateway statistics:




Returns the gateway's user name.


Returns the gateway's display name (nickname).


Returns the name of the instant messaging protocol (JABBER for XMPP, or SAMETIME).


Returns the number of messages received by the gateway since it was started.


Returns the number of messages sent by the gateway since it was started.


Sets the gateway's display name (nickname).

Gateway online status methods

The following table describes the methods that you can use to get and set the gateway's online availability status (presence information):




Returns the gateway's custom away message if the setStatus method set it.


Returns the online status of the gateway.


Returns the date/time that the gateway changed its online status.


Returns True if the gateway is connected to the IM server; otherwise, returns false.


Changes the gateway's online status; for example, to away or idle.

Gateway buddy management methods

The following table describes the methods that you can use to manage the gateway's buddy list:




Adds a buddy to the gateway's buddy list and tells the IM server to send the gateway messages with the buddy's online state.


Gets information about the specified user from the buddy list, deny list, and permit list.


Returns the gateway's buddy list.


Removes the specified user name from the gateway's buddy list and tells the IM server to stop sending the gateway messages with the user's online state.

Gateway permission management methods

The IM gateways can manage the information that other users can get about the gateway's online status.

XMPP permission management is included in the XMPP 1.0 specification, but several XMPP servers that were available at the time of the ColdFusion release do not support permission management.

The following table describes the gateway permission management methods:




Tells the IM server to add the specified user to the gateway's deny list. If the permitMode is DENY_SOME, these users cannot receive messages on the gateway's state.


Tells the IM server to add the specified user to the server's permit list. If the permitMode is PERMIT_SOME, these users receive messages on the gateway's state.


Returns the list of users that the server has been told not to send state information to.


Returns the list of users that the server has been told to send state information to.


Gets the gateway's permit mode from the IM server. The permit mode determines whether all users can get the gateway's online state information, or whether the server uses a permit list or a deny list to control which users get state information.


Removes the user from the gateway's deny list.


Removes the user from the gateway's permit list.


Sets the gateway's permit mode on the IM server.

GatewayHelper example

This example lets you use the XMPP or SameTime GatewayHelper class to get and set status and other information, including managing buddy lists and view permissions lists.

<!--- Set the gateway buddy name to default values.--->
<cfparam name="session.gwid" default="XMPP Buddy Manager">
<cfparam name="session.buddyid" default="hlichtin2@mousemail">

<!--- Reset gateway and buddy ID if form was submitted. --->
<cfif isdefined("form.submitbuddy")>
<cfset session.buddyid=form.buddyid>
<cfset session.gwid=form.gwid>

<!--- Display the current gateway and buddy ID. --->
<h3>Using the GatewayHelper</h3>
<!--- Form to display and reset gateway and Buddy ID. --->
<cfform action="#cgi.script_name#" method="post" name="changeIDs">
Current buddy ID: <cfinput type="text" name="buddyid" value="#session.buddyid#"><br>
Current gateway ID: <cfinput type="text" name="gwid" value="#session.gwid#"><br>
<cfinput name="submitbuddy" value="Change gateway/buddy" type="submit">

<!--- When a buddy is set, display the links and forms to get and set
information, and so on, Where form input is required, the form uses a GET method
so a url.cmd variable represents each selection. --->

<h3>Select one of the following to get or set.</h3>
<li><a href="#cgi.script_name#?cmd=buddyinfo">buddyinfo</a>
<li>LIST: <a href="#cgi.script_name#?cmd=buddylist">buddylist</a> |
<a href="#cgi.script_name#?cmd=permitlist">permitlist</a> |
<a href="#cgi.script_name#?cmd=denylist">denylist</a>
<li>ADD: <a href="#cgi.script_name#?cmd=addbuddy">addbuddy</a> |
<a href="#cgi.script_name#?cmd=addpermit">addpermit</a> |
<a href="#cgi.script_name#?cmd=adddeny">adddeny</a>
<li>REMOVE: <a href="#cgi.script_name#?cmd=removebuddy">removebuddy</a> |
<a href="#cgi.script_name#?cmd=removepermit">removepermit</a> |
<a href="#cgi.script_name#?cmd=removedeny">removedeny</a>
<!--- NOTE: This list does not include OFFLINE because the gateway resets itself to online. --->
<li>setStatus (XMPP):
<cfloop list="ONLINE,AWAY,DND,NA,FREE_TO_CHAT" index="e">
<a href="#cgi.script_name#?cmd=setstatus&status=#e#">#e#</a> |
<li>setStatus (Sametime):
<cfloop list="ONLINE,AWAY,DND,IDLE" index="e">
<a href="#cgi.script_name#?cmd=setstatus&status=#e#">#e#</a> |
<form action="#cgi.script_name#" method="get">
setStatus with CustomAwayMessage:
<input type="hidden" name="cmd" value="setstatus2">
<select name="status">
<option value="#e#">#e#</option>
<input type="text" name="custommsg" value="(custom away massage)" size="30"/>
<input type="submit"/>
<form action="#cgi.script_name#" method="get">
<input type="hidden" name="cmd" value="setnickname">
<input type="text" name="nickname" value="(enter nickname)">
<input type="submit">
<li>INFO: <a href="#cgi.script_name#?cmd=getname">getname</a> |
<a href="#cgi.script_name#?cmd=getnickname">getnickname</a> |
<a href="#cgi.script_name#?cmd=getcustomawaymessage">getcustomawaymessage</a> |
<a href="#cgi.script_name#?cmd=getprotocolname">getprotocolname</a> |
<a href="#cgi.script_name#?cmd=getstatusasstring">getstatusasstring</a> |
<a href="#cgi.script_name#?cmd=isonline">isonline</a>
<a href="#cgi.script_name#?cmd=numberofmessagesreceived">numberofmessagesreceived</a> |
<a href="#cgi.script_name#?cmd=numberofmessagessent">numberofmessagessent</a>
<li>RUNNING TIME: <a href="#cgi.script_name#?cmd=getsignontimestamp">getsignontimestamp</a> |
<a href="#cgi.script_name#?cmd=getstatustimestamp">getstatustimestamp</a>
index="e"><a href="#cgi.script_name#?cmd=setpermitmode&mode=#e#">#e#</a> |
</cfloop> <span class="note">doesn't work for XMPP</span>
<li><a href="#cgi.script_name#?cmd=getpermitmode">getpermitmode</a>
<cfloop list="PLAIN_TEXT,RICH_TEXT" index="e">
<a href="#cgi.script_name#?cmd=setplaintextmode&mode=#e#">#e#</a> |
<li><a href="#cgi.script_name#?cmd=getplaintextmode">getplaintextmode</a>

<!--- The url.cmd value exists if one of the previous links or forms has been submitted, and identifies the type of request. --->
<cfif isdefined("url.cmd")>
<!--- Get the GatewayHelper for the gateway. --->
<cfset helper = getGatewayHelper(session.gwid)>
<!--- Get the buddy list if the list or full buddy information was requested. --->
<cfswitch expression="#LCase(url.cmd)#">
<cfcase value="buddylist,buddyinfo">
<cfset ret=helper.getBuddyList()>
<cfcase value="denylist">
<cfset ret=helper.getDenyList()>
<cfcase value="permitlist">
<cfset ret=helper.getPermitList()>
<cfcase value="addbuddy">
<cfset ret=helper.addBuddy("#session.buddyid#",
"#session.buddyid#", "")>
<cfcase value="addpermit">
<cfset ret=helper.addPermit("#session.buddyid#",
"#session.buddyid#", "")>
<cfcase value="adddeny">
<cfset ret=helper.addDeny("#session.buddyid#",
"#session.buddyid#", "")>
<cfcase value="removebuddy">
<cfset ret=helper.removeBuddy("#session.buddyid#", "")>
<cfcase value="removepermit">
<cfset ret=helper.removePermit("#session.buddyid#", "")>
<cfcase value="removedeny">
<cfset ret=helper.removeDeny("#session.buddyid#", "")>
<cfcase value="setstatus">
<cfset ret=helper.setStatus(url.status, "")>
<cfcase value="setstatus2">
<cfset ret=helper.setStatus(url.status, url.custommsg)>
<cfcase value="getcustomawaymessage">
<cfset ret=helper.getCustomAwayMessage()>
<cfcase value="getname">
<cfset ret=helper.getName()>
<cfcase value="getnickname">
<cfset ret=helper.getNickname()>
<cfcase value="getprotocolname">
<cfset ret=helper.getProtocolName()>
<cfcase value="getsignontimestamp">
<cfset ret=helper.getSignOnTimeStamp()>
<cfcase value="getstatusasstring">
<cfset ret=helper.getStatusAsString()>
<cfcase value="getstatustimestamp">
<cfset ret=helper.getStatusTimeStamp()>
<cfcase value="isonline">
<cfset ret=helper.isOnline()>
<cfcase value="numberofmessagesreceived">
<cfset ret=helper.numberOfMessagesReceived()>
<cfcase value="numberofmessagessent">
<cfset ret=helper.numberOfMessagesSent()>
<cfcase value="setnickname">
<cfset ret=helper.setNickName(url.nickname)>
<cfcase value="setpermitmode">
<cfset ret=helper.setPermitMode(url.mode)>
<cfcase value="getpermitmode">
<cfset ret=helper.getPermitMode()>
<cfcase value="setplaintextmode">
<cfset ret=helper.setPlainTextMode(url.mode)>
<cfcase value="getplaintextmode">
<cfset ret=helper.getPlainTextMode()>
<cfset ret[1]="Error; Invalid command. You shouldn't get this.">
<!--- Display the results returned by the called GatewayHelper method. --->
<cfdump var="#ret#">
<!--- If buddy information was requested, loop through buddy list to get
information for each buddy and display it. --->
<cfif comparenocase(url.cmd, "buddyinfo") is 0 and arraylen(ret) gt 0>
<b>Buddy info for all buddies</b><br>
<cfloop index="i" from="1" to="#arraylen(ret)#">
<cfdump var="#helper.getBuddyInfo(ret[i])#" label="#ret[i]#"></cfloop>

Adobe logo

Sign in to your account