Messages in JS: Difference between revisions

From Yate Documentation
Jump to navigation Jump to search
No edit summary
Marian (talk | contribs)
No edit summary
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
In Yate, you can have access to any message. Only a handler must be installed.
From Javascript module (the same goes for external scripts) you can have access to all Yate's messages.


For examplefor routing you need to ''call.route'' message handler installed.
In order to receive a message you must install a handler.
 
You can also create, a custom MessageQueue, to avoid usage of internal Yate's message queue, if you need to handle a specific message, that takes too long to be processed by Yate.
 
 
Yate message processing:<br/>
 
'''Enqueue:'''<br/>
Check if an installed MessageQueue matches it. Put it there if so. Message will be processed by it.<br/>
Otherwise: put message in Yate internal queue. Message will be taken by an internal worker and dispatched.<br/>
 
'''Dispatch:'''<br/>
* Find a message handler matching the message (name and any parameter(s) filter). Handle return value:
** False: find another message handler
** True (message is broadcast): find another message handler
** True (message is not broadcast): stop processing
* Set message handled indication to boolean true if any handler returned true
* Call internal message dispatched function (see enqueue() function parameters)
* Pass message (read-only) and handled indication to installed post hooks matching it
* Return handled indication (boolean true/false) to caller


In Javascript you have to install handler for ''MessageQueue'' message.


{|class="yate-table"
{|class="yate-table"
Line 9: Line 27:
|-
|-
|class="yate-content-right"|
|class="yate-content-right"|
<div class="bullet">&nbsp;</div><font class="yate-page-title">[[MessageQueue]]</font><br/>
* [[Install handler for using Yate's messages in Javascript]]
<div class="yate-page-desc">The MessageQueues is used to create a mechanism for organizing YATE's messages in different queues</div>
How to install handler for messages from Javascript.
* [[Singleton (separate) message handler context in Javascript]]
How to install a message handler using a separate context in Javascript.
* [[MessageQueue]]
The MessageQueue is a mechanism for organizing Yate's messages in different queues.
|}
|}


Line 17: Line 39:


* [[Messages]]
* [[Messages]]
* [[Javascript]]
[[Category:Javascript]] [[Category:Programmers]]

Latest revision as of 05:42, 3 September 2024

From Javascript module (the same goes for external scripts) you can have access to all Yate's messages.

In order to receive a message you must install a handler.

You can also create, a custom MessageQueue, to avoid usage of internal Yate's message queue, if you need to handle a specific message, that takes too long to be processed by Yate.


Yate message processing:

Enqueue:
Check if an installed MessageQueue matches it. Put it there if so. Message will be processed by it.
Otherwise: put message in Yate internal queue. Message will be taken by an internal worker and dispatched.

Dispatch:

  • Find a message handler matching the message (name and any parameter(s) filter). Handle return value:
    • False: find another message handler
    • True (message is broadcast): find another message handler
    • True (message is not broadcast): stop processing
  • Set message handled indication to boolean true if any handler returned true
  • Call internal message dispatched function (see enqueue() function parameters)
  • Pass message (read-only) and handled indication to installed post hooks matching it
  • Return handled indication (boolean true/false) to caller


YATE's Messages in JavaScript

How to install handler for messages from Javascript.

How to install a message handler using a separate context in Javascript.

The MessageQueue is a mechanism for organizing Yate's messages in different queues.


See also