5

I have implemented ColdFusion XMPP Event Gateway in coldfusion server 10 and it is working fine with google talk. The same thing i want to implement in Railo server but no luck to find something.

Please suggest something to "Railo to talk to XMPP/Jabber/Google Talk from within Railo"

Used cfc file in coldfusion XMPP event gateway

<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>

Thanks,
Arun

Leigh
  • 28,765
  • 10
  • 55
  • 103
Arun
  • 215
  • 3
  • 11
  • Railo has [Event Gateways](https://github.com/getrailo/railo/wiki/Event-Gateways) plus the ability to [create your own type](https://github.com/getrailo/railo/wiki/Create-your-own-Event-Gateway-type) - what have you tried and where are you stuck? – Peter Boughton Sep 03 '13 at 10:11
  • @Peter. Thanks. I check this link and in "Your action here" i want to write some script to receive any instant message of my jabber/gmail account and respond to the sender. As in coldfusion XMPP event gateway we have function named "onIncomingMessage".i have added the cfc in my question.That function received the instant message for my gmail account and respond to the sender. Please see my edited question. I have added my cfc. – Arun Sep 03 '13 at 11:07

0 Answers0