Debian Codegraph @

src/modules/imc/README

raw
1 imc Module
2
3 Anca-Maria Vamanu
4
5 Voice Sistem SRL
6
7 Daniel-Constantin Mierla
8
9 <[email protected]>
10
11 Stefan Popescu
12
13 Edited by
14
15 Anca-Maria Vamanu
16
17 Joey Golan
18
19 Copyright © 2006 Voice Sistem SRL
20 __________________________________________________________________
21
22 Table of Contents
23
24 1. Admin Guide
25
26 1. Overview
27 2. Dependencies
28
29 2.1. Kamailio Modules
30 2.2. External Libraries or Applications
31
32 3. Parameters
33
34 3.1. db_url (str)
35 3.2. db_mode(integer)
36 3.3. rooms_table (str)
37 3.4. members_table (str)
38 3.5. hash_size (integer)
39 3.6. imc_cmd_start_char (str)
40 3.7. outbound_proxy (str)
41 3.8. extra_hdrs (str)
42 3.9. create_on_join (integer)
43 3.10. check_on_create (integer)
44
45 4. Functions
46
47 4.1. imc_manager()
48 4.2. imc_room_active(room)
49 4.3. imc_room_member(room, user)
50
51 5. RPC Commands
52
53 5.1. imc.list_rooms
54 5.2. imc.list_members
55
56 6. Statistics
57
58 6.1. active_rooms
59
60 7. IMC Commands
61 8. Installation
62
63 List of Examples
64
65 1.1. Set db_url parameter
66 1.2. Set db_mode parameter
67 1.3. Set rooms_table parameter
68 1.4. Set members_table parameter
69 1.5. Set hash_size parameter
70 1.6. Set imc_cmd_start_char parameter
71 1.7. Set outbound_proxy parameter
72 1.8. Set extra_hdrs parameter
73 1.9. Set create_on_join parameter
74 1.10. Set check_on_create parameter
75 1.11. Usage of imc_manager() function
76 1.12. Usage of imc_room_active() function
77 1.13. Usage of imc_room_member() function
78 1.14. List of commands
79
80 Chapter 1. Admin Guide
81
82 Table of Contents
83
84 1. Overview
85 2. Dependencies
86
87 2.1. Kamailio Modules
88 2.2. External Libraries or Applications
89
90 3. Parameters
91
92 3.1. db_url (str)
93 3.2. db_mode(integer)
94 3.3. rooms_table (str)
95 3.4. members_table (str)
96 3.5. hash_size (integer)
97 3.6. imc_cmd_start_char (str)
98 3.7. outbound_proxy (str)
99 3.8. extra_hdrs (str)
100 3.9. create_on_join (integer)
101 3.10. check_on_create (integer)
102
103 4. Functions
104
105 4.1. imc_manager()
106 4.2. imc_room_active(room)
107 4.3. imc_room_member(room, user)
108
109 5. RPC Commands
110
111 5.1. imc.list_rooms
112 5.2. imc.list_members
113
114 6. Statistics
115
116 6.1. active_rooms
117
118 7. IMC Commands
119 8. Installation
120
121 1. Overview
122
123 This module offers support for instant message conference using SIP
124 MESSAGE requests. It follows the architecture of IRC channels. The
125 conferences are managed by commands that can be sent embedded in the
126 MESSAGE body, because there are just a few SIP UA implementations which
127 have GUI for IM conferencing.
128
129 By sending a SIP MESSAGE a configured SIP URI to the IM conferencing
130 manager, the user can send commands to manage conference rooms. Once
131 the conference room is created, users can send commands directly to
132 conference's URI.
133
134 To ease the integration in the configuration file, the interpreter of
135 the IMC commands are embedded in the module. From a configuration point
136 of view, there is only one function which has to be executed for both
137 messages and commands.
138
139 2. Dependencies
140
141 2.1. Kamailio Modules
142 2.2. External Libraries or Applications
143
144 2.1. Kamailio Modules
145
146 The following modules must be loaded before this module:
147 * db_mysql.
148 * tm.
149
150 2.2. External Libraries or Applications
151
152 The following libraries or applications must be installed before
153 running Kamailio with this module loaded:
154 * None.
155
156 3. Parameters
157
158 3.1. db_url (str)
159 3.2. db_mode(integer)
160 3.3. rooms_table (str)
161 3.4. members_table (str)
162 3.5. hash_size (integer)
163 3.6. imc_cmd_start_char (str)
164 3.7. outbound_proxy (str)
165 3.8. extra_hdrs (str)
166 3.9. create_on_join (integer)
167 3.10. check_on_create (integer)
168
169 3.1. db_url (str)
170
171 The database url.
172
173 The default value is “mysql://kamailio:kamailiorw@localhost/kamailio”.
174
175 Example 1.1. Set db_url parameter
176 ...
177 modparam("imc", "db_url", "dbdriver://username:password@dbhost/dbname")
178 ...
179
180 3.2. db_mode(integer)
181
182 The module supports 2 modes of operation, high speed memory based
183 storage (mode 0), and database only (mode 2) where all data is stored
184 in a database, allowing scalability at the expense of speed. Mode 1 is
185 reserved.
186
187 Default value is “0”
188
189 Example 1.2. Set db_mode parameter
190 ...
191 modparam("imc", "db_mode", 2)
192 ...
193
194 3.3. rooms_table (str)
195
196 The name of the table storing IMC rooms.
197
198 The default value is "imc_rooms".
199
200 Example 1.3. Set rooms_table parameter
201 ...
202 modparam("imc", "rooms_table", "rooms")
203 ...
204
205 3.4. members_table (str)
206
207 The name of the table storing IMC members.
208
209 The default value is "imc_members".
210
211 Example 1.4. Set members_table parameter
212 ...
213 modparam("imc", "members_table", "members")
214 ...
215
216 3.5. hash_size (integer)
217
218 The power of 2 to get the size of the hash table used for storing
219 members and rooms.
220
221 The default value is 4 (resulting in hash size 16).
222
223 Example 1.5. Set hash_size parameter
224 ...
225 modparam("imc", "hash_size", 8)
226 ...
227
228 3.6. imc_cmd_start_char (str)
229
230 The character which indicates that the body of the message is a
231 command.
232
233 The default value is "#".
234
235 Example 1.6. Set imc_cmd_start_char parameter
236 ...
237 modparam("imc", "imc_cmd_start_char", "#")
238 ...
239
240 3.7. outbound_proxy (str)
241
242 The SIP address used as next hop when sending the message. Very useful
243 when using Kamailio with a domain name not in DNS, or when using a
244 separate Kamailio instance for imc processing. If not set, the message
245 will be sent to the address in destination URI.
246
247 Default value is NULL.
248
249 Example 1.7. Set outbound_proxy parameter
250 ...
251 modparam("imc", "outbound_proxy", "sip:kamailio.org;transport=tcp")
252 ...
253
254 3.8. extra_hdrs (str)
255
256 Extra headers (each ending with \r\n) to be added in messages sent out
257 from imc server.
258
259 Default value is NULL.
260
261 Example 1.8. Set extra_hdrs parameter
262 ...
263 modparam("imc", "extra_hdrs", "P-Flags: 3\r\n")
264 ...
265
266 3.9. create_on_join (integer)
267
268 If set to 1 and user requests to join a non-existing room, the room
269 will be automatically created. If set to 0, joining a non-existing room
270 returns an error.
271
272 The default value is 1.
273
274 Example 1.9. Set create_on_join parameter
275 ...
276 modparam("imc", "create_on_join", 0)
277 ...
278
279 3.10. check_on_create (integer)
280
281 If set to 1, the chat server will report an error if the user attempts
282 to create a room that already exists.
283
284 The default value is 0.
285
286 Example 1.10. Set check_on_create parameter
287 ...
288 modparam("imc", "check_on_create", 1)
289 ...
290
291 4. Functions
292
293 4.1. imc_manager()
294 4.2. imc_room_active(room)
295 4.3. imc_room_member(room, user)
296
297 4.1. imc_manager()
298
299 THis function handles incoming MESSAGE requests. If detects if the body
300 of the message is a conference command it executes it, otherwise it
301 sends the message to all the members in the room.
302
303 This function can be used from REQUEST_ROUTE. See command description
304 for error codes returned by this function.
305
306 Example 1.11. Usage of imc_manager() function
307 ...
308 # the rooms will be named chat-xyz to avoid overlapping
309 # with usernames
310 if(is_method("MESSAGE)
311 && (uri=~ "sip:chat-[0-9]+@" || (uri=~ "sip:chat-manager@"))
312 {
313 if(imc_manager())
314 sl_send_reply("200", "ok");
315 else
316 sl_send_reply("500", "command error");
317 exit;
318 }
319 ...
320
321 4.2. imc_room_active(room)
322
323 Return 1 (true) if the room is active, -1 (false) if the room is not
324 found. The parameter is the SIP URI to identify the room, it can
325 contain variables.
326
327 This function can be used from ANY_ROUTE.
328
329 Example 1.12. Usage of imc_room_active() function
330 ...
331 if(imc_room_active("sip:chat-sip@$fd")) {
332 ...
333 }
334 ...
335
336 4.3. imc_room_member(room, user)
337
338 Return 1 (true) if the user is member of the room, -1 (false) if the
339 user is not member of the room. The parameters are the SIP URIs to
340 identify the room and the user, they can contain variables.
341
342 This function can be used from ANY_ROUTE.
343
344 Example 1.13. Usage of imc_room_member() function
345 ...
346 if(imc_room_member("sip:chat-sip@$fd", "sip:$rU@$rd")) {
347 ...
348 }
349 ...
350
351 5. RPC Commands
352
353 5.1. imc.list_rooms
354 5.2. imc.list_members
355
356 5.1. imc.list_rooms
357
358 Lists of the IM Conferencing rooms.
359
360 Name: imc.list_rooms
361
362 Parameters: none
363
364 RPC Command Format:
365 ...
366 kamctl rpc imc_list_rooms
367 ...
368
369 5.2. imc.list_members
370
371 Listing of the members in IM Conferencing rooms.
372
373 Name: imc.list_members
374
375 Parameters:
376 * _room_ : the room for which you want to list the members
377
378 RPC Command Format:
379 ...
380 kamctl rpc imc_list_members _room_
381 ...
382
383 6. Statistics
384
385 6.1. active_rooms
386
387 6.1. active_rooms
388
389 Number of active IM Conferencing rooms.
390
391 7. IMC Commands
392
393 A command is identified by the starting character. A command must be
394 written in one line. By default, the starting character is '#'. You can
395 change it via "imc_cmd_start_char" parameter.
396
397 Next picture presents the list of commands and their parameters.
398
399 Example 1.14. List of commands
400 ...
401
402 1.create
403 -creates a conference room
404 -takes 2 parameters:
405 1) the name of the room
406 2)optional- "private" -if present the created room is private
407 and new members can be added only though invitations
408 -the user is added as the first member and owner of the room
409 -eg: #create chat-000 private
410 -error case: return codes: -30 -- -39
411
412 2.join
413 -makes the user member of a room
414 -takes one optional parameter - the address of the room -if not
415 present it will be considered to be the address in the To
416 header of the message
417 -if the room does not exist the command is treated as create
418 -eg:join sip:[email protected],
419 or just, #join, sent to sip:[email protected]
420 -error case: return codes: -40 -- -49
421
422 3.invite
423 -invites a user to become a member of a room
424 -takes 2 parameters:
425 1)the complete address of the user
426 2)the address of the room -if not present it will be considered
427 to be the address in the To header of the message
428 -only certain users have the right to invite other user: the owner
429 and the administrators
430 -eg: #invite sip:[email protected] sip:[email protected]
431 or #invite [email protected] sent to sip:[email protected]
432 -error case: return codes: -50 -- -59
433
434 4.accept
435 -accepting an invitation
436 -takes one optional parameter - the address of the room - if not
437 present it will be considered to be the address in the To header
438 of the message
439 -eg: #accept sip:[email protected]
440 -error case: return codes: -60 -- -69
441
442 5.reject
443 -rejects an invitation
444 -the parameter is the same as for accept
445 -error case: return codes: -70 -- -79
446
447 6.remove
448 -deletes a member from a room
449 -takes 2 parameters:
450 1)the complete address of the member
451 2)the address of the room -if not present it will be considered
452 to be the address in the To header of the message
453 -only certain members have the right to remove other members
454 -eg: #remove sip:[email protected], sent to sip:[email protected]
455 -error case: return codes: -80 -- -89
456
457 7.leave
458 -leaving a room
459 -takes one optional parameter - the address of the room - if not
460 present it will be considered to be the address in the To header
461 of the message
462 -if the user is the owner of the room, the room will be destroyed
463 -error case: return codes: -90 -- -99
464
465 8.destroy
466 -removing a room
467 -the parameter is the same as for leave
468 -only the owner of a room has the right to destroy it
469 -error case: return codes: -110 -- -119
470
471 9.members
472 -list members in a room
473 -error case: return codes: -100 -- -109
474
475 10.add
476 -adds a user to a room
477 -takes 2 parameters:
478 1)the complete address of the user
479 2)the address of the room -if not present it will be considered
480 to be the address in the To header of the message
481 -only certain users have the right to add other users: the owner
482 and the administrators
483 -eg: #add sip:[email protected] sip:[email protected]
484 or #add [email protected] sent to sip:[email protected]
485 -error case: return codes: -50 -- -59
486
487 11.modify
488 -modify user role in a room
489 -takes 3 parameters:
490 1)the complete address of the user
491 2)the role of the user
492 3)the address of the room -if not present it will be considered
493 to be the address in the To header of the message
494 -only certain users have the right to invite other user: the owner
495 and the administrators
496 -roles: owner, admin, member
497 -eg: #invite sip:[email protected] admin sip:[email protected]
498 or #invite [email protected] admin sent to sip:[email protected]
499 -error case: return codes: -120 -- -129
500 ...
501
502 8. Installation
503
504 Before running Kamailio with IMC, you have to set up the database
505 tables where the module will store the data. For that, if the tables
506 were not created by the installation script or you choose to install
507 everything by yourself you can use the imc-create.sql SQL script in the
508 database directories in the kamailio/scripts folder as template. You
509 can also find the complete database documentation on the project
510 webpage,
511 https://www.kamailio.org/docs/db-tables/kamailio-db-devel.html.