Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 1289

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using External Resources
}else{
retrunVal.message = "Records found: #employees.recordCount#";
}
// The session.users structure contains the found names.
// The record key is a number that is also returned in front of the
// name in the message.
session.users = structNew();
for(i=1; i lte min(10, employees.recordCount); i=i+1)
{
// These two lines are formatted to prevent extra white space.
retrunVal.message = retrunVal.message & "
#i# - #employees.firstName[i]# #employees.lastName[i]#";
// The following two lines must be a single line in the source
session.users[i]="#employees.firstName[i]#
}
}
return retrunVal;
</cfscript>
</cffunction>
</cfcomponent>
Status and request-handling CFC
The following CFC handles all IM events, except onIncomingMessage. It maintains an Application scope buddyStatus
structure that contains information on the gateway buddies. This structure limits the interactions that are needed with
the IM server to get buddy and status information. The application also logs significant events, such as requests to add
buddies and error messages from the IM server. In particular, it does the following:
• The
function updates the Application scope buddy status structure when the gateway gets an event
onBuddyStatus
message indicating that a buddy's status has changed.
• The
onAddBuddyRequest
instance of the name, it adds the buddy and updates the status in the Application scope buddyStatus structure. If it
doesn't find name, it declines the buddy request. If it finds multiple instances of the name, it tells the gateway to
take no action. It also logs all actions.
• The
onAddBuddyResponse
request is accepted, and sets the current status. It logs all responses.
• The
onIMServerMessage
This example uses the IM_ID column of the Employees database of the cfdocexamples database that is included
with ColdFusion. The entries in this column assume that you use an XMPP server "company." To run this
exampleconfigure an XMPP server with this name and with clients with names in this database, or change the
database entries to match IM server clients. Also, configure a gateway instance in the ColdFusion Administrator
that uses this server.
The following listing shows the CFC code:
#employees.lastName[i]#";
function searches for the requested buddy's name in a data source. If it finds a single
function adds the buddy to the Application scope buddy status structure if the buddy
function logs all messages that it receives.
Last updated 1/20/2012
1284

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents