- Publicity: Public Only All
message-relay-procs.tcl
Generic MessageRelay procs Provide means to publish a subscription key and let clients write to these keys. These functions are used e.g. by the chat.
This file defines the following Objects and Classes: ::xo::MessageRelay, ::xo::mr::bgdelivery, ::xo::mr::connchan, ::xo::mr::none, ::xo::MessageRelay, ::xo::MessageRelay, ::xo::MessageRelay, ::xo::MessageRelay, ::xo::MessageRelay, ::xo::MessageRelay, ::xo::mr::bgdelivery, ::xo::mr::bgdelivery, ::xo::mr::bgdelivery, ::xo::mr::bgdelivery, ::xo::mr::connchan, ::xo::mr::connchan, ::xo::mr::connchan, ::xo::mr::connchan, ::xo::mr::connchan, ::xo::MessageRelay, ::xo::mr::connchan, ::xo::MessageRelay, ::xo::mr::bgdelivery, ::xo::mr::bgdelivery, ::xo::mr::connchan, ::xo::MessageRelay, ::xo::mr::connchan, ::xo::mr::connchan, ::xo::MessageRelay
- Location:
- packages/xotcl-core/tcl/message-relay-procs.tcl
- Created:
- 2019-02-23
- Author:
- Gustaf Neumann
Procedures in this file
- Class ::xo::MessageRelay (public)
- Object ::xo::mr::bgdelivery (public)
- Object ::xo::mr::connchan (public)
- Object ::xo::mr::none (public)
- xo::MessageRelay instproc can_be_used (public)
- xo::MessageRelay instproc encode_message (public)
- xo::MessageRelay instproc send_to_subscriber (public)
- xo::MessageRelay instproc subscribe (public)
- xo::MessageRelay instproc sweep (public)
- xo::mr::bgdelivery proc can_be_used (public)
- xo::mr::bgdelivery proc send_to_subscriber (public)
- xo::mr::bgdelivery proc subscribe (public)
- xo::mr::bgdelivery proc sweep (public)
- xo::mr::connchan proc can_be_used (public)
- xo::mr::connchan proc send_to_subscriber (public)
- xo::mr::connchan proc subscribe (public)
- xo::mr::connchan proc sweep (public)
Detailed information
Class ::xo::MessageRelay (public)
::nx::Class ::xo::MessageRelay
Generic Message Relay class
- Testcases:
- No testcase defined.
Object ::xo::mr::bgdelivery (public)
::xo::MessageRelay ::xo::mr::bgdelivery
Message relay based on bgdelivery
Object ::xo::mr::connchan (public)
::xo::MessageRelay ::xo::mr::connchan
Message relay based on ns_connchan
xo::MessageRelay method can_be_used (public)
<instance of xo::MessageRelay> can_be_used
Check, if a message relay can be used in the current configuration.
- Testcases:
- No testcase defined.
xo::MessageRelay method encode_message (public)
<instance of xo::MessageRelay> encode_message mode msg
Provide different "encoding" depending on the mode. Notice that for one chat, multiple clients might have difference modes, since the modes are determined at also by the capabilities of the client browser. So the incoming message has to be recoded multiple times.
- Parameters:
- mode (required)
- msg (required)
- Testcases:
- No testcase defined.
xo::MessageRelay method send_to_subscriber (public)
<instance of xo::MessageRelay> send_to_subscriber key msg
Send a message to a service identified by the key (communication hub).
- Parameters:
- key (required)
- id for an existing communication hub
- msg (required)
- message to be sent
- Testcases:
- No testcase defined.
xo::MessageRelay method subscribe (public)
<instance of xo::MessageRelay> subscribe [ -initmsg initmsg ] \ [ -mode mode ] key
Subscribe to a service identified by a key.
- Switches:
- -initmsg (optional)
- optional message to be sent, when subscription happens
- -mode (optional, defaults to
"default"
)- optional mode
- Parameters:
- key (required)
- unique id for a (potentially new communication hub)
- Testcases:
- No testcase defined.
xo::MessageRelay method sweep (public)
<instance of xo::MessageRelay> sweep key
Check existing subscriptions and clean stale ones.
- Parameters:
- key (required)
- key of the communication hub
- Testcases:
- No testcase defined.
xo::mr::bgdelivery proc can_be_used (public)
xo::mr::bgdelivery can_be_used
To use the bgdelivery serive, we require support from the web server, an installed bgdelivery. This method does not work on HTTPS, since this method writes to the raw sockets.
- Testcases:
- No testcase defined.
xo::mr::bgdelivery proc send_to_subscriber (public)
xo::mr::bgdelivery send_to_subscriber key msg
Send a message to the subscriber via bgdelivery
- Parameters:
- key (required)
- msg (required)
- Testcases:
- No testcase defined.
xo::mr::bgdelivery proc subscribe (public)
xo::mr::bgdelivery subscribe [ -initmsg initmsg ] [ -mode mode ] key
Subscribe to a messaging service using bgdelivery as the low level transport.
- Switches:
- -initmsg (optional)
- -mode (optional, defaults to
"default"
)- Parameters:
- key (required)
- Testcases:
- No testcase defined.
xo::mr::bgdelivery proc sweep (public)
xo::mr::bgdelivery sweep key
Clean up messages for this key. This should handle potentially stale operations.
- Parameters:
- key (required)
- Testcases:
- No testcase defined.
xo::mr::connchan proc can_be_used (public)
xo::mr::connchan can_be_used
ns_connchan can be used on every recent NaviServer.
- Testcases:
- No testcase defined.
xo::mr::connchan proc send_to_subscriber (public)
xo::mr::connchan send_to_subscriber key msg
Write directly to the subscribers from the connection thread via ns_connchan. It would be possible, to perform asynchronous operations via "ns_connchan callback", which would be handled in the background. Not sure, this is necessary.
- Parameters:
- key (required)
- msg (required)
- Testcases:
- No testcase defined.
xo::mr::connchan proc subscribe (public)
xo::mr::connchan subscribe [ -initmsg initmsg ] [ -mode mode ] key
ns_log notice "#### [self] subscribe $key mode $mode" Unplug the connection channel from the current connection thread. The currently unplugged channels can be queried via "ns_connchan list"
- Switches:
- -initmsg (optional)
- -mode (optional)
- Parameters:
- key (required)
- Testcases:
- No testcase defined.
xo::mr::connchan proc sweep (public)
xo::mr::connchan sweep key
For the time being, do nothing. Since the chat is verbose on logins/logouts, write operations will fail, in which case the array is cleaned up. If this is not sufficient, probably a "ns_connchan eof" operation would be useful.
- Parameters:
- key (required)
- Testcases:
- No testcase defined.