Whatever message this page gives is out now! Go check it out!
onAddBuddyRequest(CFEvent) |
| 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, onAddBuddyRequest. |
data.MESSAGE | The message that was sent with the request |
data.SENDER | The sender's ID; identical to the originatorID field value |
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 |
| Field | Description |
command | One of the following:
|
buddyID | ID to which to send the message. Normally, the value of the CFEvent.data.SENDER field. Not used with the noact command. |
reason | A text message describing the reason for the action. Not used with the noact command. |
<cffunction name="onAddBuddyRequest"> <cfargument name="CFEvent" type="struct" required="YES"> <cfquery name="buddysearch" datasource="cfdocexamples"> SELECT IM_ID FROM Employees WHERE IM_ID = '#CFEvent.Data.SENDER#' </cfquery> <cflock scope="APPLICATION" timeout="10" type="EXCLUSIVE"> <cfscript> // If the name is in the DB once, accept; if it is missing, decline. // If it is in the DB multiple times, take no action. if (buddysearch.RecordCount IS 0) { action="decline"; reason="Invalid ID"; } else if (buddysearch.RecordCount IS 1) { action="accept"; reason="Valid ID"; //Add the buddy to the buddy status structure only if accepted. if (NOT StructKeyExists(Application, "buddyStatus")) { Application.buddyStatus=StructNew(); } if (NOT StructKeyExists(Application.buddyStatus, CFEvent.Data.SENDER)) { Application.buddyStatus[#CFEvent.Data.SENDER#]=StructNew(); } Application.buddyStatus[#CFEvent.Data.SENDER#].status= "Accepted Buddy Request"; Application.buddyStatus[#CFEvent.Data.SENDER#].timeStamp= CFEvent.Data.TIMESTAMP; Application.buddyStatus[#CFEvent.Data.SENDER#].message= CFEvent.Data.MESSAGE; } else { action="noact"; } </cfscript> </cflock> <!--- Log the request and decision information. ---> <cflog file="#CFEvent.GatewayID#Status" text="onAddBuddyRequest; SENDER: #CFEvent.Data.SENDER# MESSAGE: #CFEvent.Data.MESSAGE# TIMESTAMP: #CFEvent.Data.TIMESTAMP# ACTION: #action#"> <!--- Return the action decision. ---> <cfset retValue = structNew()> <cfset retValue.command = action> <cfset retValue.BuddyID = CFEvent.DATA.SENDER> <cfset retValue.Reason = reason> <cfreturn retValue> </cffunction> |