• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

event gateway handling

New Here ,
Jun 30, 2009 Jun 30, 2009

Copy link to clipboard

Copied

Hi i am using the main.cfc in the examples using the onIncomingMessage event

i am gettnig back a variable

<cfset message="#data.message#">

<!--- where did it come from? --->
<cfset orig="#CFEvent.originatorID#">
<cfset retValue = structNew()>
<cfset retValue.command = "submit">
<cfset retValue.sourceAddress = arguments.CFEVENT.gatewayid>
<cfset retValue.destAddress = arguments.CFEVENT.originatorid>
<cfset retValue.shortMessage = "echo: " & message>

retValue.shortMessage contains all the data and is then written to a text file like this

"Information","Thread-15","06/30/09","21:07:17","IM_MENU","echo: id:869990453 sub:001 dlvrd:001 submit date:0906301507 done date:0906301507 stat:DELIVRD err:000 text:"

what i need is to set 2 variables

1. MessageId = this is the "id" in the echo

2. MessageStatus = this is the "stat"

i am not sure how to get to this info?

TOPICS
Advanced techniques

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 30, 2009 Jun 30, 2009

Copy link to clipboard

Copied

Hi,

could you please paste ur main.cfc

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 30, 2009 Jun 30, 2009

Copy link to clipboard

Copied

main.cfc below, instead of writing to a txt file i need to create 2 variables to insert into my database

<cffunction name="onIncomingMessage" output="no">
<cfargument name="CFEvent" type="struct" required="yes">

<!--- Get the message --->
<cfset data=cfevent.DATA>

<cfset message="#data.message#">

<!--- where did it come from? --->
<cfset orig="#CFEvent.originatorID#">
<cfset retValue = structNew()>
<cfset retValue.command = "submit">
<cfset retValue.sourceAddress = arguments.CFEVENT.gatewayid>
<cfset retValue.destAddress = arguments.CFEVENT.originatorid>
<cfset retValue.shortMessage = "echo: " & messageId>

<cflog file="smsTest" text="#retValue.shortMessage#">

</cffunction>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 30, 2009 Jun 30, 2009

Copy link to clipboard

Copied

Hi,

try this

<cfset temp= listgetat(retValue.shortMessage,6)>
<cfset temparray= listtoarray(temp," ")>
<cfset MessageId  = listgetat(temparray[2],2,":")>
<cfset MessageStatus  = listgetat(temparray[9],2,":")>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 30, 2009 Jun 30, 2009

Copy link to clipboard

Copied

Hi i have tried the below, which did not work, i am not sure how i can debug this to find what the error is, as its a event?

<cfcomponent>
<cffunction name="onIncomingMessage" output="no">
<cfargument name="CFEvent" type="struct" required="yes">

<!--- Get the message --->
<cfset data=cfevent.DATA>
<cfset message="#data.message#">

<!--- where did it come from? --->
<cfset orig="#CFEvent.originatorID#">
<cfset retValue = structNew()>
<cfset retValue.command = "submit">
<cfset retValue.sourceAddress = arguments.CFEVENT.gatewayid>
<cfset retValue.destAddress = arguments.CFEVENT.originatorid>
<cfset retValue.shortMessage = "echo: " & message>

<cfset temp= listgetat(retValue.shortMessage,6)>
<cfset temparray= listtoarray(temp," ")>
<cfset MessageId  = listgetat(temparray[2],2,":")>
<cfset MessageStatus  = listgetat(temparray[9],2,":")>


<cflog file="smsTestCraig2" text="#MessageStatus#">


</cffunction>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 30, 2009 Jun 30, 2009

Copy link to clipboard

Copied

Use cflog to save information about the request to a log file.

Here's the same statement as above but this time correctly escaped in code tags:

ReFindNoCase("id:([0-9]+) .*stat:([a-z]+) ", retValue.shortMessage, 1, true)

Mack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 30, 2009 Jun 30, 2009

Copy link to clipboard

Copied

ok thanks i have added the following, but nothing is written to the log file

<cflog file="smsTestCraig2" text="#ReFindNoCase("id:([0-9]+) .*stat:([a-z]+) ", retValue.shortMessage, 1, true)#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 30, 2009 Jun 30, 2009

Copy link to clipboard

Copied

That's because the ReFindNoCase returns a structure and the text

attribute expects a string (or something that can be converted to a

string).

Test the regular expression outside the cfc, in a simple test file to

make sure it's working properly and place the code inside the CFC

after that.

Mack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 01, 2009 Jul 01, 2009

Copy link to clipboard

Copied

try this

<cfset st1=ReFindNoCase("id:([0-9]+) .*stat:([a-z]+) ", retValue.shortMessage, 1, true)>

<cfloop index = "i" from = "2" to = "#ArrayLen(st1.pos)#">
    <cfset testval  = testval & Mid(t,st1.pos,st1.len) & "|">
</cfloop>

<cflog file="smsTestCraig2" text="#testval #">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 07, 2009 Jul 07, 2009

Copy link to clipboard

Copied

ok i have tried the following in a test file, but i just get 2 empty strings?


<cfset retValue.shortMessage = "echo: id:869990453 sub:001 dlvrd:001 submit date:0906301507 done date:0906301507 stat:DELIVRD err:000 text:">
<cfset testval = "">

<cfset st1=ReFindNoCase("id:([0-9]+) .*stat:([a-z]+) ", retValue.shortMessage, 1, true)>

<cfloop index = "i" from = "2" to = "#ArrayLen(st1.pos)#">
    <cfset testval = testval & Mid(true, st1.pos,st1.len) & "|">

</cfloop>

<cfdump var="#testval#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 07, 2009 Jul 07, 2009

Copy link to clipboard

Copied

The first parameter of the Mid function is not a boolean but the

string from which you want to extract the substring.

Mack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 08, 2009 Jul 08, 2009

Copy link to clipboard

Copied

LATEST

hi so what should the first value be?

i have tried st1?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 30, 2009 Jun 30, 2009

Copy link to clipboard

Copied

ReFindNoCase("id:() .*stat:() ", retValue.shortMessage, 1,

true) will get you the position and length of the id and stat in the

message (you can use Mid to extract them).

Mack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation