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

event gateway handling

Guest
Jun 30, 2009 Jun 30, 2009

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
2.2K
Translate
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

Hi,

could you please paste ur main.cfc

Translate
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
Guest
Jun 30, 2009 Jun 30, 2009

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>

Translate
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

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,":")>

Translate
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
Guest
Jun 30, 2009 Jun 30, 2009

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>

Translate
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

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

Translate
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
Guest
Jun 30, 2009 Jun 30, 2009

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)#">

Translate
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

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

Translate
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

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

Translate
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
Guest
Jul 07, 2009 Jul 07, 2009

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

Translate
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

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

string from which you want to extract the substring.

Mack

Translate
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
Guest
Jul 08, 2009 Jul 08, 2009
LATEST

hi so what should the first value be?

i have tried st1?

Translate
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

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

Translate
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