[Freeswitch-users] chat messages aren't being forwarded to the second user
Steve Kieu
msh.computing at gmail.com
Fri Sep 12 03:51:29 MSD 2014
It is just the header string sometimes - what I did is serialize the
'message:serialize()' and see all header string and craft them similar in
my custom event.
With that I got it working see below
freeswitch.consoleLog("info", "chat console\n");
local event = freeswitch.Event("CUSTOM", "SMS::SEND_MESSAGE");
event:addHeader("proto", "sip");
event:addHeader("dest_proto", "sip");
event:addHeader("from", message:getHeader("from"));
event:addHeader("from_host", 'YOURS');
event:addHeader("from_full", message:getHeader("from_full"));
event:addHeader("to", to);
event:addHeader("to_user", 'YOURS' );
event:addHeader("to_host", 'YOURS');
event:addHeader("type", message:getHeader("type"))
msg = message:getBody()
if (msg) then
event:addBody(msg)
end
-- freeswitch.consoleLog("info", event:serialize());
-- freeswitch.consoleLog("info", message:serialize());
event:fire();
On Mon, Sep 8, 2014 at 6:35 PM, Snabel Kabiya <snabel at lexifone.com> wrote:
> Hi,
>
> I'm using Linphone to test mod_sms on smart phones, the chat messages
> aren't being forwarded to the second user.
> I've two registered users 3333 and 4444. when i use action "send" the
> message is forwarded, but when i use my script with event fire it's
> not...what am i missing?
>
> *public.xml:*
>
> <?xml version="1.0" encoding="utf-8"?>
> <include>
> <context name="public">
> <extension name="public">
> <condition field="to" expression="^(.*)$">
> <action application="lua" data="handle_chat.lua"/>
> <action application="reply" data="Hello, you said:
> ${_body}"/>
> <!--action application="send"/-->
> </condition>
> </extension>
> </context>
> </include>
>
>
> *handle_chat.lua*
>
> local body = message:getBody();
> local from = message:getHeader("from");
> local to = message:getHeader("to");
> freeswitch.consoleLog("info", message:getHeader("from"));
> freeswitch.consoleLog("info", message:getHeader("to"));
> freeswitch.consoleLog("info", message:serialize());
> freeswitch.consoleLog("info", message:getBody() .. "\n");
> local event = freeswitch.Event("CUSTOM", "SMS::SEND_MESSAGE");
> event:addHeader("proto", "sip");
> event:addHeader("dest_proto", "sip");
> event:addHeader("from", "sip:" .. from);
> event:addHeader("from_full", "sip:" .. from);
> event:addHeader("to", to);
> event:addHeader("type", "text/html");
> event:addHeader("replying", "true");
> event:addBody("Hello from Seven Du! Have funnnnnnn!");
> freeswitch.consoleLog("info", event:serialize());
> event:fire();
>
>
>
> Thanks,
> Snabel
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
>
>
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
--
Steve Kieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140912/023fb6c5/attachment.html
Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users
mailing list