Handles incoming responses from other users to requests from the gateway to be added to their buddy lists. Also receives requests from buddies to have you remove them from your buddy list.
onAddBuddyResponse(CFEvent)
onIncomingMessage, onAddBuddyRequest, onBuddyStatus, onIMServerMessage
The method must take one parameter, a CFEvent structure with the following fields:
Field |
Description |
---|---|
gatewayType |
Gateway type, either XMPP or SAMETIME. |
gatewayID |
The ID of the gateway instance, as configured in ColdFusion Administrator. |
originatorID |
The IM ID of the message originator. |
cfcMethod |
This CFC method; by default, onAddBuddyResponse. |
data.MESSAGE |
One of the following:
|
data.SENDER |
The sender's ID; identical to the originatorID. |
data.RECIPIENT |
The recipient's ID, as specified in the gateway's configuration file. |
data.TIMESTAMP |
The date and time when the message was sent. |
The function does not return a value.
The following example adds the buddy's status to the Application scope buddyStatus structure if the message sender accepted an add buddy request. It logs all responses.
<cffunction name="onAddBuddyResponse"> <cfargument name="CFEvent" type="struct" required="YES"> <cflock scope="APPLICATION" timeout="10" type="EXCLUSIVE"> <cfscript> //Do the following only if the buddy accepted the request. if (NOT StructKeyExists(Application, "buddyStatus")) { Application.buddyStatus=StructNew(); } if (#CFEVENT.Data.MESSAGE# IS "accept") { //Create a new entry in the buddyStatus record for the buddy. if (NOT StructKeyExists(Application.buddyStatus, CFEvent.Data.SENDER)) { Application.buddyStatus[#CFEvent.Data.SENDER#]=StructNew(); } //Set the buddy status information to indicate buddy was added. Application.buddyStatus[#CFEvent.Data.SENDER#].status= "Buddy accepted us"; Application.buddyStatus[#CFEvent.Data.SENDER#].timeStamp= CFEvent.Data.TIMESTAMP; Application.buddyStatus[#CFEvent.Data.SENDER#].message= CFEvent.Data.MESSAGE; } </cfscript> </cflock> <!--- Log the information for all responses. ---> <cflog file="#CFEvent.GatewayID#Status" text="onAddBuddyResponse; BUDDY: #CFEvent.Data.SENDER# RESPONSE: #CFEvent.Data.MESSAGE# TIMESTAMP: #CFEvent.Data.TIMESTAMP#"> </cffunction>