5

我已经在 Coldfusion 服务器 10 中实现了 ColdFusion XMPP 事件网关,它与 google talk 运行良好。我想在 Railo 服务器中实现同样的事情,但没有运气找到一些东西。

请向“Railo 提出一些建议,以便从 Railo 内部与 XMPP/Jabber/Google Talk 交谈”

在 Coldfusion XMPP 事件网关中使用了 cfc 文件

<cfcomponent displayname="EventGateway" hint="Process events from the test gateway and return echo">
    <cffunction name="onIncomingMessage" output="no">
        <cfargument name="CFEvent" type="struct" required="yes">

        <cflog file="#CFEvent.GatewayID#Status" text=" onIncomingMessage; SENDER: #CFEvent.Data.SENDER# MESSAGE:
#CFEvent.Data.MESSAGE# TIMESTAMP: #CFEvent.Data.TIMESTAMP# ">

        <!--- Get the message --->
        <cfset data=cfevent.DATA>
        <cfset message="#data.message#">
        <!--- where did it come from? --->
        <cfset orig="#CFEvent.originatorID#">
        <cfset retValue = structNew()>
        <cfif listcontains("XMPP ", arguments.CFEVENT.GatewayType) gt 0>
            <cfset retValue.BuddyID = orig>
            <cfset retValue.MESSAGE = "echo: " & message>
        <cfelseif arguments.CFEVENT.GatewayType is "Socket">
            <cfset retValue.originatorID = orig>
            <cfset retValue.message = "echo: " & message>
        <cfelseif arguments.cfevent.gatewaytype is "SMS">
            <cfset retValue.command = "submit">
            <cfset retValue.sourceAddress = arguments.CFEVENT.GatewayID>
            <cfset retValue.destAddress = orig>
            <cfset retValue.shortMessage = "echo: " & message>
        </cfif>

        <!--- we can write our script to process like database Query here --->

        <!--- send the return message back --->
        <cfreturn retValue>
    </cffunction>

    <cffunction name="onAddBuddyRequest">
        <cfargument name="CFEvent" type="struct" required="YES">

        <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.
            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;
            </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>

    <cffunction name="onAddBuddyResponse">
    </cffunction>

    <cffunction name="onBuddyStatus">
    </cffunction>

    <cffunction name="onIMServerMessage">
    </cffunction>
</cfcomponent>

谢谢,
阿伦

4

0 回答 0