• 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[i], ::xo::mr::bgdelivery[i], ::xo::mr::connchan[i], ::xo::mr::none[i], ::xo::MessageRelay[i], ::xo::MessageRelay[i], ::xo::MessageRelay[i], ::xo::MessageRelay[i], ::xo::MessageRelay[i], ::xo::MessageRelay[i], ::xo::mr::bgdelivery[i], ::xo::mr::bgdelivery[i], ::xo::mr::bgdelivery[i], ::xo::mr::bgdelivery[i], ::xo::mr::connchan[i], ::xo::mr::connchan[i], ::xo::mr::connchan[i], ::xo::mr::connchan[i], ::xo::mr::connchan[i], ::xo::MessageRelay[i], ::xo::mr::connchan[i], ::xo::MessageRelay[i], ::xo::mr::bgdelivery[i], ::xo::mr::bgdelivery[i], ::xo::mr::connchan[i], ::xo::MessageRelay[i], ::xo::mr::connchan[i], ::xo::mr::connchan[i], ::xo::MessageRelay[i]

Location:
packages/xotcl-core/tcl/message-relay-procs.tcl
Created:
2019-02-23
Author:
Gustaf Neumann

Procedures in this file

Detailed information

Class ::xo::MessageRelay (public)

 ::nx::Class ::xo::MessageRelay[i]

Generic Message Relay class

Testcases:
No testcase defined.

xo::MessageRelay method can_be_used (public)

 <instance of xo::MessageRelay[i]> 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[i]> 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[i]> 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[i]> 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[i]> 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[i] 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[i] 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[i] 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[i] 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[i] 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[i] 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[i] 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[i] 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.
[ show source ]