summaryrefslogtreecommitdiffstats
path: root/tcllib/modules/multiplexer/multiplexer.man
blob: d47e822bd3de9e8f32a596149777755ebd7195b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
[comment {-*- tcl -*- doctools manpage}]
[comment { $Id: multiplexer.man,v 1.11 2009/01/29 06:16:20 andreas_kupries Exp $ }]
[manpage_begin multiplexer n 0.2]
[keywords chat]
[keywords multiplexer]
[moddesc   {One-to-many communication with sockets.}]
[titledesc {One-to-many communication with sockets.}]
[category  {Programming tools}]
[require Tcl 8.2]
[require logger]
[require multiplexer [opt 0.2]]
[description]

The [package multiplexer] package provides a generic system for one-to-many
communication utilizing sockets.  For example, think of a chat system
where one user sends a message which is then broadcast to all the
other connected users.

[para]

It is possible to have different multiplexers running concurrently.

[list_begin definitions]

[call [cmd ::multiplexer::create]]

The [cmd create] command creates a new multiplexer 'instance'.  For
example:

[example {set mp [::multiplexer::create]}]

This instance can then be manipulated like so: [example {${mp}::Init 35100}]

[call [cmd \${multiplexer_instance}::Init] [arg port]]

This starts the multiplexer listening on the specified port.

[call [cmd \${multiplexer_instance}::Config] [arg key] [arg value]]

Use [cmd Config] to configure the multiplexer instance.  Configuration
options currently include:

[list_begin options]

[opt_def sendtoorigin]

A boolean flag. If [const true], the sender will receive a copy of the
sent message.  Defaults to [const false].

[opt_def debuglevel]

Sets the debug level to use for the multiplexer instance, according to
those specified by the [package logger] package (debug, info, notice,
warn, error, critical).

[list_end]

[call [cmd \${multiplexer_instance}::AddFilter] [arg cmdprefix]]

Command to add a filter for data that passes through the multiplexer
instance.

The registered [arg cmdprefix] is called when data arrives at a
multiplexer instance. If there is more than one filter command
registered at the instance they will be called in the order of
registristation, and each filter will get the result of the preceding
filter as its argument. The first filter gets the incoming data as its
argument. The result returned by the last filter is the data which
will be broadcast to all clients of the multiplexer instance.

The command prefix is called as

[list_begin definitions]
[call [cmd cmdprefix] [arg data] [arg chan] [arg clientaddress] [arg clientport]]

Takes the incoming [arg data], modifies it, and returns that as its
result. The last three arguments contain information about the client
which sent the data to filter: The channel connecting us to the
client, its ip-address, and its ip-port.

[list_end]

[call [cmd \${multiplexer_instance}::AddAccessFilter] [arg cmdprefix]]

Command to add an access filter.

The registered [arg cmdprefix] is called when a new client socket
tries to connect to the multixer instance. If there is more than one
access filter command registered at the instance they will be called
in the order of registristation. If any of the called commands returns
[const -1] the access to the multiplexer instance is denied and the
client channel is closed immediately. Any other result grants the
client access to the multiplexer instance.

The command prefix is called as

[list_begin definitions]
[call [cmd cmdprefix] [arg chan] [arg clientaddress] [arg clientport]]

The arguments contain information about the client which tries to
connected to the instance: The channel connecting us to the client,
its ip-address, and its ip-port.

[list_end]

[call [cmd \${multiplexer_instance}::AddExitFilter] [arg cmdprefix]]

Adds filter to be run when client socket generates an EOF condition.

The registered [arg cmdprefix] is called when a client socket of the
multixer signals EOF. If there is more than one exit filter command
registered at the instance they will be called in the order of
registristation. Errors thrown by an exit filter are ignored, but
logged. Any result returned by an exit filter is ignored.

The command prefix is called as

[list_begin definitions]
[call [cmd cmdprefix] [arg chan] [arg clientaddress] [arg clientport]]

The arguments contain information about the client which signaled the
EOF: The channel connecting us to the client, its ip-address, and its
ip-port.

[list_end]
[list_end]

[vset CATEGORY multiplexer]
[include ../doctools2base/include/feedback.inc]
[manpage_end]