Openser中文网

专注于VoIP,Opensips,Kamailio等技术,QQ群:QQ群:293697898

Kamailio模块文档imc翻译


tags:Kamailio模块imc 中文 翻译 创建时间:2015-12-12 21:25:28

This page was saved using WebZIP 7.0.3.1030 offline browser (Unregistered) on 10/03/15 23:42:10. Address: http://kamailio.org/docs/modules/stable/modules/imc.html Title: imc Module • Size: 31557 • Last Modified: Wed, 03 Jun 2015 20:25:53 GMT imc Module

Anca-Maria Vamanu

Voice Sistem SRL
Daniel-Constantin Mierla

<miconda@gmail.com>
Stefan Popescu

Edited by

Anca-Maria Vamanu

翻译

李 浩

<1354608370@qq.com>
Copyright © 2006 Voice Sistem SRL

目录

1. 用户指南
1. 概述
2. 依赖模块
2.1. Kamailio 模块
2.2. 外部库或应用程序
3. 参数表
3.1. db_url (str)
3.2. rooms_table (str)
3.3. members_table (str)
3.4. hash_size (integer)
3.5. imc_cmd_start_char (str)
3.6. outbound_proxy (str)
3.7. extra_hdrs (str)
4. 函数表
4.1. imc_manager()
5. MI 命令
5.1. imc_list_rooms
5.2. imc_list_members
6. 统计
6.1. active_rooms
7. IMC 命令
8. 安装手册
示例

1.1. Set db_url parameter
1.2. Set rooms_table parameter
1.3. Set members_table parameter
1.4. Set hash_size parameter
1.5. Set imc_cmd_start_char parameter
1.6. Set outbound_proxy parameter
1.7. Set extra_hdrs parameter
1.8. Usage of imc_manager() function
1.9. List of commands
第1节. 用户指南

目录

1. 概述
2. 依赖模块
2.1. Kamailio 模块
2.2. 外部库或应用程序
3. 参数表
3.1. db_url (str)
3.2. rooms_table (str)
3.3. members_table (str)
3.4. hash_size (integer)
3.5. imc_cmd_start_char (str)
3.6. outbound_proxy (str)
3.7. extra_hdrs (str)
4. 函数表
4.1. imc_manager()
5. MI 命令
5.1. imc_list_rooms
5.2. imc_list_members
6. 统计
6.1. active_rooms
7. IMC 命令
8. 安装手册
1.概述

This module offers support for instant message conference. It follows the architecture of IRC channels, you can send commands embedded in MESSAGE body, because there are just a few SIP UA clients which have GUI for IM conferencing. 
这个模块通常用于即时消息会议。你可以按照IRC channels的要求,发送嵌入到SIP Message body中的命令, 因为仅仅只有一小部分SIP UA客户端有IM会议的GUI.

You have to define an URI corresponding to im conferencing manager, where user can send commands to create a new conference room. Once the conference room is created, users can send commands directly to conferece's URI. 
你不得不去定义一个URI和IM 会议管理对应,任何用户可以发送命令去创建一个会议室。 当会议室已创建,用户可以发送命令直接送给会议的 URI.

To ease the integration in the configuration file, the interpreter of the IMC commands are embeded in the module. From a configuration point of view, there is only one function which has to be executed for both messages and commands. 
为了便于集成到配置文件中,IMC 的解释器嵌入到了模块中,从配置文件来说,只有一个函数被执行,针对消息和命令。

2.依赖模块

2.1. Kamailio 模块

The following modules must be loaded before this module: 
依赖模块必须要本模块前加载

db_mysql.

tm.

2.2.外部库或应用程序

The following libraries or applications must be installed before running Kamailio with this module loaded: 
依赖的外部库或应用程序必须在加载本模块前被安装:

None.

3.参数表

3.1. db_url (str)

The database url.

默认值: “mysql://kamailio:kamailiorw@localhost/kamailio”.

示例 1.1. Set db_url parameter

...
modparam("imc", "db_url", "dbdriver://username:password@dbhost/dbname")
...

3.2. rooms_table (str)

The name of the table storing IMC rooms. 
表里存储的IMC room的字段名称

默认值: "imc_rooms".

示例 1.2. Set rooms_table parameter

...
modparam("imc", "rooms_table", "rooms")
...

3.3. members_table (str)

The name of the table storing IMC members. 
表里存储的IMC 成员的字段名称。

默认值: "imc_members".

Example 1.3. Set members_table parameter

...
modparam("imc", "members_table", "members")
...

3.4. hash_size (integer)

The power of 2 to get the size of the hash table used for storing members and rooms. 
从第2大点中的表里获得hash表里成员和会议室的大小。

默认值: 4 (resultimg in hash size 16).

示例 1.4. Set hash_size parameter

...
modparam("imc", "hash_size", 8)
...

3.5. imc_cmd_start_char (str)

The character which indicates that the body of the message is a command. 
标记消息是一个命令的字符。

默认值: "#".

示例 1.5. Set imc_cmd_start_char parameter

...
modparam("imc", "imc_cmd_start_char", "#")
...

3.6. outbound_proxy (str)

The SIP address used as next hop when sending the message. Very useful when using Kamailio with a domain name not in DNS, or when using a separate Kamailio instance for imc processing. If not set, the message will be sent to the address in destination URI. 
当发送消息时,这个SIP地址被用作下一跳。当使用kamailio的domain name 不在NDS时,这是非常有用的。 如果没有配置,那么消息将被发送到目标URI 中的地址。

默认值: NULL.

示例 1.6. Set outbound_proxy parameter

...
modparam("imc", "outbound_proxy", "sip:kamailio.org;transport=tcp")
...

3.7. extra_hdrs (str)

Extra headers (each ending with \r\n) to be added in messages sent out from imc server. 
额外的headers(每个以\r\n结束)将被添加到消息并从Imc服务发出。

默认值: NULL.

示例 1.7. Set extra_hdrs parameter

...
modparam("imc", "extra_hdrs", "P-Flags: 3\r\n")
...

4.函数表

4.1.  imc_manager()

Handles Message method.It detects if the body of the message is a conference command.If so it executes it, otherwise it sends the message to all the members in the room. 
处理消息的方法,它检测消息主体是不是一个会议命令,如果是,将执行它,如果不是,则发送给所有会议室内的成员。

This function can be used from REQUEST_ROUTE. See command description for error codes returned by this function.
这个函数可被用于REQUEST_ROUTE,这个函数的错误码可看命令说明。

示例 1.8. Usage of imc_manager() function

...
# the rooms will be named chat-xyz to avoid overlapping
# with usernames
if(is_method("MESSAGE)
    && (uri=~ "sip:chat-[0-9]+@" || (uri=~ "sip:chat-manager@"))
{
    if(imc_manager())
        sl_send_reply("200", "ok");
    else
        sl_send_reply("500", "command error");
    exit;
}
...

5. MI 命令

5.1.  imc_list_rooms

Lists of the IM Conferencing rooms. 
例出所有的IM会议室。

Name: imc_list_rooms

Parameters: none

MI FIFO Command Format:

        :imc_list_rooms:_reply_fifo_file_
        _empty_line_
5.2.  imc_list_members

Listing of the members in IM Conferencing rooms. 
列出所有IM会议室成员

Name: imc_list_members

Parameters:

_room_ : the room for which you want to list the members 
要列出成员的会议室

MI FIFO Command Format:

        :imc_list_members:_reply_fifo_file_
        _room_
        _empty_line_
6.统计

6.1.  active_rooms

Number of active IM Conferencing rooms.

7. IMC 命令

A command is identified by the starting character. A command must be written in one line. By default, the starting character is '#'. You can change it via "imc_cmd_start_char" parameter. 
一个命令由开始字符标识,命令必须是一行。默认情况下,开始字符是'#'.你可以用 "imc_cmd_start_char"参数替换它。

Next picture presents the list of commands and their parameters. 
下一张图介绍了命令和它们的参数

示例 1.9. List of commands

...

1.create
  -creates a conference room

  创建一个会议室

  -takes 2 parameters:

  有两个参数

     1) the name of the room

     会议室名称

     2)optional- "private" -if present the created room is private
       and new members can be added only though invitations

       选项 - "private" -  如果现在创建的会议室是私有的,那么只能通过邀请添加新成员。


  -the user is added as the first member and owner of the room

  用户作为第一个成员加入将有会议室的所有权
  -eg:  #create chat-000 private
  -error case: return codes: -30 -- -39

2.join
  -makes the user member of a room

  使一个用户成为一个会议室成员。


  -takes one optional parameter - the address of the room -if not
    present it will be considered to be the address in the To
    header of the message

    可选参数 - 会议室地址,如果不是当前的,它将被认为是消息中的To header中的地址。

  -if the room does not exist the command is treated as create

  如果会议室不存在,这个命令将被认为是和create一样执行。
  -eg:join sip:chat-000@kamailio.org,
      or just, #join, sent to sip:chat-000@kamailio.org
  -error case: return codes: -40 -- -49

3.invite
  -invites a user to become a member of a room

  邀请一个用户加入会议室。

  -takes 2 parameters:
     1)the complete address of the user

     用户的完整地址

     2)the address of the room -if not present it will be considered

       to be the address in the To header of the message

       会议室的地址,如果没有指定它,那么将用消息中的To Header中的地址。

  -only certain users have the right to invite other user: the owner 
    and the administrators

    仅有些用户有权邀请其他用户:所有者和管理员。

  -eg: #invite sip:john@kamailio.org sip:chat-000@kamailio.org

    or  #invite john@kamailio.org sent to sip:chat-000@kamailio.org
  -error case: return codes: -50 -- -59

4.accept
  -accepting an invitation

  允许一个邀请

  -takes one optional parameter - the address of the room - if not
    present it will be considered to be the address in the To header
    of the message

    可选参数 - 会议室地址,如果不是当前的,它将被认为是消息中的To header中的地址。
  -eg: #accept sip:john@kamailio.org
  -error case: return codes: -60 -- -69

5.deny
  -rejects an invitation

  拒绝一个邀请
  -the parameter is the same as for accept
  参数等同于accept
  -error case: return codes: -70 -- -79

6.remove
  -deletes a member from a room

  从会议室中删除一个成员

  -takes 2 parameters:
    1)the complete address of the member

    会议成员的完整地址
    2)the address of the room -if not present it will be considered
      to be the address in the To header of the message

       会议室地址,如果不是当前的,它将被认为是消息中的To header中的地址。
  -only certain members have the right to remove other members
  -eg: #remove sip:john@kamailio.org, sent to sip:chat-000@kamailio.org
  -error case: return codes: -80 -- -89

7.exit
  -leaving a room

  离开一个会议室
  -takes one optional parameter - the address of the room - if not
    present it will be considered to be the address in the To header
    of the message
    可选参数 - 会议室地址,如果不是当前的,它将被认为是消息中的To header中的地址。
  -if the user is the owner of the room, the room will be destroyed
  如果用户是会议室所有者,那么会议室将被解散
  -error case: return codes: -90 -- -99

8.destroy
  -removing a room
  移除一个会议室
  -the parameter is the same as for exit
  参数等同于exit
  -only the owner of a room has the right to destroy it
  仅所有者有权释放会议室
  -error case: return codes: -110 -- -119

9.list
  -list members in a room
  列出会议室成员
  -error case: return codes: -100 -- -109

...

8. Installation

Before running Kamailio with IMC, you have to setup the database tables where the module will store the data. For that, if the tables were not created by the installation script or you choose to install everything by yourself you can use the imc-create.sql SQL script in the database directories in the kamailio/scripts folder as template. You can also find the complete database documentation on the project webpage, http://www.kamailio.org/docs/db-tables/kamailio-db-devel.html.

在运行Kamailio的IMC之前,你必须配置数据表用于模块储存数据。因为,如果表不是由安装脚本创建的或你选择安装自己去使用imc-create.sql 。SQL脚本的数据库目录在kamailio/scriptes文件夹下。 你也可以找到完整的数据库文档在项目主页,http://www.kamailio.org/docs/db-tables/kamailio-db-devel.html.


如果在有疑问或需要沟通的地方,可以QQ:1354608370 或 加FreeSWITCH+Kamailio+Opensips QQ群: 293697898 沟通交流!