How to setup chat and short file transfer using MESSAGE Request Method

From Yate Documentation
(Difference between revisions)
Jump to: navigation, search
Line 9: Line 9:
  
 
Both MESSAGE and PUBLISH requests are one of the [[SIP_Methods#Generically_handled_Methods|generically handled]] methods in Yate. This means that when MESSAGE request is received, Yate won't handle it automatically, but a sip.message yate message will be emitted. The handling of the message is custom and can be done from [[Regular_expressions|regexroute]]/[[External_Module|external module]]/custom yate module.
 
Both MESSAGE and PUBLISH requests are one of the [[SIP_Methods#Generically_handled_Methods|generically handled]] methods in Yate. This means that when MESSAGE request is received, Yate won't handle it automatically, but a sip.message yate message will be emitted. The handling of the message is custom and can be done from [[Regular_expressions|regexroute]]/[[External_Module|external module]]/custom yate module.
 
 
  
 
== Configuration ==
 
== Configuration ==

Revision as of 11:22, 2 September 2013

This example explains how to setup chat and short files transfer between Twinkle clients.

For setting chat, the SIP MESSAGE request method is used to transports instant messages.

Both MESSAGE and PUBLISH requests are one of the generically handled methods in Yate. This means that when MESSAGE request is received, Yate won't handle it automatically, but a sip.message yate message will be emitted. The handling of the message is custom and can be done from regexroute/external module/custom yate module.

Configuration

regexroute.conf:

[extra]
sip.message=120
sip.publish=120
msg.route=25
msg.execute=90

[sip.message]
${xsip_type}^$=415
.*=echo Got SIP MESSAGE type '${xsip_type}' ${xsip_body_encoding} from '${username}': ${xsip_body}
.*=enqueue msg.execute;caller=${caller};called=${called};\
 domain=${domain};callto=lateroute/${called};\
 body_encoding=${xsip_body_encoding};type=${xsip_type};text=${xsip_body}
.*=200
  
[sip.publish]
${xsip_type}^application/pidf+xml$^=415
${xsip_body}<status><basic>\(.*\)</basic></status>=echo Got SIP PRESENCE from '${username}': \1
.*=200

[msg.route]
.*=rename call.route;message=msg.route

[msg.execute]
${callto}^sip/\(sip:.*\)$=rename xsip.generate;\
method=MESSAGE;uri=\1;sip_From=<sip:${caller}@${domain$nosuch.dom}>;\
xsip_type=${type$text/plain};xsip_body_encoding=${body_encoding};\
xsip_body=${text};connection_id=${oconnection_id}


In ysipchan.conf:

[general]
maxpkt=4096
generate=yes

[methods]
message=yes
publish=yes

To configure twinkle clients, register users in regfile.conf:

[123]
password=mypass123

[234]
password=mypass234

The flow of the messages in Yate

Yate receives a SIP MESSAGE Request. This will be handled generically, so a Yate message named sip.message will be sent.

  • Regexroute receives this message:
    • If xsip_type parameter is not set, a 415 error code will be returned in SIP module. Otherwise pass to the below steps.
    • Echo a message for debug purpose.
    • Enqueue msg.execute message in which we'll copy the parameters defining message: caller, called, domain, body_encoding, type, text. In order to deliver the message we have to find the URI for the receiving end, and for that we use lateroute. Set callto=lateroute/${called}.
    • Handle message and return code 200 OK.
  • Lateroute module receives the msg.execute message and sends msg.route message with called parameter the ${called} from above
  • Regexroute receives msg.route and renames it to call.route
  • Another module(regfile in current setup) handles call.route and returns the uri for which we need to deliver the received chat message.
  • Lateroute replaces callto parameter with the returned value of the call.route message and leaves msg.execute unhandled
  • msg.execute is received in regexroute and is renamed to xsip.generate if callto param is a valid SIP uri.
  • xsip.generate will be handled by ysipchan module that will finish delivering the chat message. Ysipchan will emit a MESSAGE request and will send it to the SIP uri specified in xsip.generate.


See also

Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers