|
onAddBuddyResponse
DescriptionHandles
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.
SyntaxonAddBuddyResponse(CFEvent)
ParametersThe
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:
accept The
request was accepted.
decline The request was declined, or the buddy is asking
you to remove them from your list.
|
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.
|
ReturnsThe
function does not return a value.
ExampleThe
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>
|