Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
698fa045
提交
698fa045
authored
8月 03, 2010
作者:
Andrew Thompson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add 3 new commands; session_event, session_noevents, session_nixevent
上级
64a28ee9
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
149 行增加
和
8 行删除
+149
-8
handle_msg.c
src/mod/event_handlers/mod_erlang_event/handle_msg.c
+127
-0
mod_erlang_event.c
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
+22
-8
没有找到文件。
src/mod/event_handlers/mod_erlang_event/handle_msg.c
浏览文件 @
698fa045
...
@@ -308,6 +308,57 @@ static switch_status_t handle_msg_event(listener_t *listener, int arity, ei_x_bu
...
@@ -308,6 +308,57 @@ static switch_status_t handle_msg_event(listener_t *listener, int arity, ei_x_bu
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
static
switch_status_t
handle_msg_session_event
(
listener_t
*
listener
,
erlang_msg
*
msg
,
int
arity
,
ei_x_buff
*
buf
,
ei_x_buff
*
rbuf
)
{
char
atom
[
MAXATOMLEN
];
if
(
arity
==
1
)
{
ei_x_encode_tuple_header
(
rbuf
,
2
);
ei_x_encode_atom
(
rbuf
,
"error"
);
ei_x_encode_atom
(
rbuf
,
"badarg"
);
}
else
{
session_elem_t
*
session
;
if
((
session
=
find_session_elem_by_pid
(
listener
,
&
msg
->
from
)))
{
int
custom
=
0
;
switch_event_types_t
type
;
int
i
=
0
;
for
(
i
=
1
;
i
<
arity
;
i
++
)
{
if
(
!
ei_decode_atom
(
buf
->
buff
,
&
buf
->
index
,
atom
))
{
if
(
custom
)
{
switch_core_hash_insert
(
session
->
event_hash
,
atom
,
MARKER
);
}
else
if
(
switch_name_event
(
atom
,
&
type
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
type
==
SWITCH_EVENT_ALL
)
{
uint32_t
x
=
0
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"ALL events enabled for %s
\n
"
,
session
->
uuid_str
);
for
(
x
=
0
;
x
<
SWITCH_EVENT_ALL
;
x
++
)
{
session
->
event_list
[
x
]
=
1
;
}
}
if
(
type
<=
SWITCH_EVENT_ALL
)
{
session
->
event_list
[
type
]
=
1
;
}
if
(
type
==
SWITCH_EVENT_CUSTOM
)
{
custom
++
;
}
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"enable event %s for session %s
\n
"
,
atom
,
session
->
uuid_str
);
}
}
ei_x_encode_atom
(
rbuf
,
"ok"
);
}
else
{
ei_x_encode_tuple_header
(
rbuf
,
2
);
ei_x_encode_atom
(
rbuf
,
"error"
);
ei_x_encode_atom
(
rbuf
,
"notlistening"
);
}
}
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
handle_msg_nixevent
(
listener_t
*
listener
,
int
arity
,
ei_x_buff
*
buf
,
ei_x_buff
*
rbuf
)
static
switch_status_t
handle_msg_nixevent
(
listener_t
*
listener
,
int
arity
,
ei_x_buff
*
buf
,
ei_x_buff
*
rbuf
)
{
{
char
atom
[
MAXATOMLEN
];
char
atom
[
MAXATOMLEN
];
...
@@ -352,6 +403,58 @@ static switch_status_t handle_msg_nixevent(listener_t *listener, int arity, ei_x
...
@@ -352,6 +403,58 @@ static switch_status_t handle_msg_nixevent(listener_t *listener, int arity, ei_x
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
}
static
switch_status_t
handle_msg_session_nixevent
(
listener_t
*
listener
,
erlang_msg
*
msg
,
int
arity
,
ei_x_buff
*
buf
,
ei_x_buff
*
rbuf
)
{
char
atom
[
MAXATOMLEN
];
if
(
arity
==
1
)
{
ei_x_encode_tuple_header
(
rbuf
,
2
);
ei_x_encode_atom
(
rbuf
,
"error"
);
ei_x_encode_atom
(
rbuf
,
"badarg"
);
}
else
{
session_elem_t
*
session
;
if
((
session
=
find_session_elem_by_pid
(
listener
,
&
msg
->
from
)))
{
int
custom
=
0
;
int
i
=
0
;
switch_event_types_t
type
;
for
(
i
=
1
;
i
<
arity
;
i
++
)
{
if
(
!
ei_decode_atom
(
buf
->
buff
,
&
buf
->
index
,
atom
))
{
if
(
custom
)
{
switch_core_hash_delete
(
session
->
event_hash
,
atom
);
}
else
if
(
switch_name_event
(
atom
,
&
type
)
==
SWITCH_STATUS_SUCCESS
)
{
uint32_t
x
=
0
;
if
(
type
==
SWITCH_EVENT_CUSTOM
)
{
custom
++
;
}
else
if
(
type
==
SWITCH_EVENT_ALL
)
{
for
(
x
=
0
;
x
<=
SWITCH_EVENT_ALL
;
x
++
)
{
session
->
event_list
[
x
]
=
0
;
}
}
else
{
if
(
session
->
event_list
[
SWITCH_EVENT_ALL
])
{
session
->
event_list
[
SWITCH_EVENT_ALL
]
=
0
;
for
(
x
=
0
;
x
<
SWITCH_EVENT_ALL
;
x
++
)
{
session
->
event_list
[
x
]
=
1
;
}
}
session
->
event_list
[
type
]
=
0
;
}
}
}
}
ei_x_encode_atom
(
rbuf
,
"ok"
);
}
else
{
/* no session for this pid */
ei_x_encode_tuple_header
(
rbuf
,
2
);
ei_x_encode_atom
(
rbuf
,
"error"
);
ei_x_encode_atom
(
rbuf
,
"notlistening"
);
}
}
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
handle_msg_api
(
listener_t
*
listener
,
erlang_msg
*
msg
,
int
arity
,
ei_x_buff
*
buf
,
ei_x_buff
*
rbuf
)
static
switch_status_t
handle_msg_api
(
listener_t
*
listener
,
erlang_msg
*
msg
,
int
arity
,
ei_x_buff
*
buf
,
ei_x_buff
*
rbuf
)
{
{
char
api_cmd
[
MAXATOMLEN
];
char
api_cmd
[
MAXATOMLEN
];
...
@@ -649,8 +752,12 @@ static switch_status_t handle_msg_tuple(listener_t *listener, erlang_msg * msg,
...
@@ -649,8 +752,12 @@ static switch_status_t handle_msg_tuple(listener_t *listener, erlang_msg * msg,
ret
=
handle_msg_set_log_level
(
listener
,
arity
,
buf
,
rbuf
);
ret
=
handle_msg_set_log_level
(
listener
,
arity
,
buf
,
rbuf
);
}
else
if
(
!
strncmp
(
tupletag
,
"event"
,
MAXATOMLEN
))
{
}
else
if
(
!
strncmp
(
tupletag
,
"event"
,
MAXATOMLEN
))
{
ret
=
handle_msg_event
(
listener
,
arity
,
buf
,
rbuf
);
ret
=
handle_msg_event
(
listener
,
arity
,
buf
,
rbuf
);
}
else
if
(
!
strncmp
(
tupletag
,
"session_event"
,
MAXATOMLEN
))
{
ret
=
handle_msg_session_event
(
listener
,
msg
,
arity
,
buf
,
rbuf
);
}
else
if
(
!
strncmp
(
tupletag
,
"nixevent"
,
MAXATOMLEN
))
{
}
else
if
(
!
strncmp
(
tupletag
,
"nixevent"
,
MAXATOMLEN
))
{
ret
=
handle_msg_nixevent
(
listener
,
arity
,
buf
,
rbuf
);
ret
=
handle_msg_nixevent
(
listener
,
arity
,
buf
,
rbuf
);
}
else
if
(
!
strncmp
(
tupletag
,
"session_nixevent"
,
MAXATOMLEN
))
{
ret
=
handle_msg_session_nixevent
(
listener
,
msg
,
arity
,
buf
,
rbuf
);
}
else
if
(
!
strncmp
(
tupletag
,
"api"
,
MAXATOMLEN
))
{
}
else
if
(
!
strncmp
(
tupletag
,
"api"
,
MAXATOMLEN
))
{
ret
=
handle_msg_api
(
listener
,
msg
,
arity
,
buf
,
rbuf
);
ret
=
handle_msg_api
(
listener
,
msg
,
arity
,
buf
,
rbuf
);
}
else
if
(
!
strncmp
(
tupletag
,
"bgapi"
,
MAXATOMLEN
))
{
}
else
if
(
!
strncmp
(
tupletag
,
"bgapi"
,
MAXATOMLEN
))
{
...
@@ -726,6 +833,26 @@ static switch_status_t handle_msg_atom(listener_t *listener, erlang_msg * msg, e
...
@@ -726,6 +833,26 @@ static switch_status_t handle_msg_atom(listener_t *listener, erlang_msg * msg, e
ei_x_encode_atom
(
rbuf
,
"error"
);
ei_x_encode_atom
(
rbuf
,
"error"
);
ei_x_encode_atom
(
rbuf
,
"notlistening"
);
ei_x_encode_atom
(
rbuf
,
"notlistening"
);
}
}
}
else
if
(
!
strncmp
(
atom
,
"session_noevents"
,
MAXATOMLEN
))
{
session_elem_t
*
session
;
if
((
session
=
find_session_elem_by_pid
(
listener
,
&
msg
->
from
)))
{
void
*
pop
;
uint8_t
x
=
0
;
/*purge the event queue */
while
(
switch_queue_trypop
(
session
->
event_queue
,
&
pop
)
==
SWITCH_STATUS_SUCCESS
);
for
(
x
=
0
;
x
<=
SWITCH_EVENT_ALL
;
x
++
)
{
session
->
event_list
[
x
]
=
0
;
}
/* wipe the hash */
switch_core_hash_destroy
(
&
session
->
event_hash
);
switch_core_hash_init
(
&
session
->
event_hash
,
session
->
pool
);
ei_x_encode_atom
(
rbuf
,
"ok"
);
}
else
{
ei_x_encode_tuple_header
(
rbuf
,
2
);
ei_x_encode_atom
(
rbuf
,
"error"
);
ei_x_encode_atom
(
rbuf
,
"notlistening"
);
}
}
else
if
(
!
strncmp
(
atom
,
"exit"
,
MAXATOMLEN
))
{
}
else
if
(
!
strncmp
(
atom
,
"exit"
,
MAXATOMLEN
))
{
ei_x_encode_atom
(
rbuf
,
"ok"
);
ei_x_encode_atom
(
rbuf
,
"ok"
);
ret
=
SWITCH_STATUS_TERM
;
ret
=
SWITCH_STATUS_TERM
;
...
...
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
浏览文件 @
698fa045
...
@@ -149,16 +149,30 @@ static void send_event_to_attached_sessions(listener_t *listener, switch_event_t
...
@@ -149,16 +149,30 @@ static void send_event_to_attached_sessions(listener_t *listener, switch_event_t
}
}
if
((
s
=
(
session_elem_t
*
)
switch_core_hash_find
(
listener
->
sessions
,
uuid
)))
{
if
((
s
=
(
session_elem_t
*
)
switch_core_hash_find
(
listener
->
sessions
,
uuid
)))
{
switch_log_printf
(
SWITCH_CHANNEL_UUID_LOG
(
s
->
uuid_str
),
SWITCH_LOG_DEBUG
,
"Sending event %s to attached session %s
\n
"
,
int
send
=
0
;
switch_event_name
(
event
->
event_id
),
s
->
uuid_str
);
if
(
s
->
event_list
[
SWITCH_EVENT_ALL
])
{
if
(
switch_event_dup
(
&
clone
,
event
)
==
SWITCH_STATUS_SUCCESS
)
{
send
=
1
;
/* add the event to the queue for this session */
}
else
if
((
s
->
event_list
[
event
->
event_id
]))
{
if
(
switch_queue_trypush
(
s
->
event_queue
,
clone
)
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
event
->
event_id
!=
SWITCH_EVENT_CUSTOM
||
!
event
->
subclass_name
||
(
switch_core_hash_find
(
s
->
event_hash
,
event
->
subclass_name
)))
{
switch_log_printf
(
SWITCH_CHANNEL_UUID_LOG
(
s
->
uuid_str
),
SWITCH_LOG_ERROR
,
"Lost event!
\n
"
);
send
=
1
;
switch_event_destroy
(
&
clone
);
}
}
if
(
send
)
{
switch_log_printf
(
SWITCH_CHANNEL_UUID_LOG
(
s
->
uuid_str
),
SWITCH_LOG_DEBUG
,
"Sending event %s to attached session %s
\n
"
,
switch_event_name
(
event
->
event_id
),
s
->
uuid_str
);
if
(
switch_event_dup
(
&
clone
,
event
)
==
SWITCH_STATUS_SUCCESS
)
{
/* add the event to the queue for this session */
if
(
switch_queue_trypush
(
s
->
event_queue
,
clone
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_UUID_LOG
(
s
->
uuid_str
),
SWITCH_LOG_ERROR
,
"Lost event!
\n
"
);
switch_event_destroy
(
&
clone
);
}
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_UUID_LOG
(
s
->
uuid_str
),
SWITCH_LOG_ERROR
,
"Memory Error!
\n
"
);
}
}
}
else
{
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_UUID_LOG
(
s
->
uuid_str
),
SWITCH_LOG_ERROR
,
"Memory Error!
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_UUID_LOG
(
s
->
uuid_str
),
SWITCH_LOG_DEBUG
,
"Ignoring event %s for attached session %s
\n
"
,
switch_event_name
(
event
->
event_id
),
s
->
uuid_str
);
}
}
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论