Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
d5e5fb03
提交
d5e5fb03
authored
9月 13, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add funcs to binary seralize/deserialize switch_events into a contiguous binary frame
上级
c28c99c3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
108 行增加
和
1 行删除
+108
-1
switch_event.h
src/include/switch_event.h
+16
-0
switch_event.c
src/switch_event.c
+92
-1
没有找到文件。
src/include/switch_event.h
浏览文件 @
d5e5fb03
...
...
@@ -102,6 +102,20 @@ struct switch_event {
int
flags
;
};
typedef
struct
switch_serial_event_s
{
int
event_id
;
int
priority
;
int
flags
;
char
*
owner
;
char
*
subclass_name
;
char
*
body
;
}
switch_serial_event_t
;
typedef
struct
switch_serial_event_header_s
{
char
*
name
;
char
*
value
;
}
switch_serial_event_header_t
;
typedef
enum
{
EF_UNIQ_HEADERS
=
(
1
<<
0
),
EF_NO_CHAT_EXEC
=
(
1
<<
1
),
...
...
@@ -295,6 +309,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_free_subclass_detailed(const char *
\return SWITCH_STATUS_SUCCESS if the operation was successful
\note you must free the resulting string when you are finished with it
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_event_binary_deserialize
(
switch_event_t
**
eventp
,
void
**
data
,
switch_size_t
len
,
switch_bool_t
destroy
);
SWITCH_DECLARE
(
switch_status_t
)
switch_event_binary_serialize
(
switch_event_t
*
event
,
void
**
data
,
switch_size_t
*
len
);
SWITCH_DECLARE
(
switch_status_t
)
switch_event_serialize
(
switch_event_t
*
event
,
char
**
str
,
switch_bool_t
encode
);
SWITCH_DECLARE
(
switch_status_t
)
switch_event_serialize_json
(
switch_event_t
*
event
,
char
**
str
);
SWITCH_DECLARE
(
switch_status_t
)
switch_event_create_json
(
switch_event_t
**
event
,
const
char
*
json
);
...
...
src/switch_event.c
浏览文件 @
d5e5fb03
...
...
@@ -34,7 +34,7 @@
#include <switch.h>
#include <switch_event.h>
#include "tpl.h"
//#define SWITCH_EVENT_RECYCLE
#define DISPATCH_QUEUE_LEN 100
...
...
@@ -1284,6 +1284,97 @@ SWITCH_DECLARE(switch_status_t) switch_event_dup_reply(switch_event_t **event, s
return
SWITCH_STATUS_SUCCESS
;
}
#define SWITCH_SERIALIZED_EVENT_MAP "S(iiisss)A(S(ss))"
SWITCH_DECLARE
(
switch_status_t
)
switch_event_binary_deserialize
(
switch_event_t
**
eventp
,
void
**
data
,
switch_size_t
len
,
switch_bool_t
destroy
)
{
switch_event_t
*
event
;
tpl_node
*
tn
;
switch_serial_event_t
e
;
switch_serial_event_header_t
sh
;
int
how
=
TPL_MEM
;
switch_event_create
(
&
event
,
SWITCH_EVENT_CLONE
);
switch_assert
(
event
);
tn
=
tpl_map
(
SWITCH_SERIALIZED_EVENT_MAP
,
&
e
,
&
sh
);
if
(
!
destroy
)
{
how
|=
TPL_EXCESS_OK
;
}
tpl_load
(
tn
,
how
,
data
,
len
);
tpl_unpack
(
tn
,
0
);
event
->
event_id
=
e
.
event_id
;
event
->
priority
=
e
.
priority
;
event
->
flags
=
e
.
flags
;
event
->
owner
=
e
.
owner
;
event
->
subclass_name
=
e
.
subclass_name
;
event
->
body
=
e
.
body
;
while
(
tpl_unpack
(
tn
,
1
))
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
sh
.
name
,
sh
.
value
);
}
*
eventp
=
event
;
tpl_free
(
tn
);
if
(
destroy
)
{
free
(
*
data
);
}
*
data
=
NULL
;
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_event_binary_serialize
(
switch_event_t
*
event
,
void
**
data
,
switch_size_t
*
len
)
{
tpl_node
*
tn
;
switch_serial_event_t
e
;
switch_serial_event_header_t
sh
;
switch_event_header_t
*
eh
;
int
how
=
TPL_MEM
;
e
.
event_id
=
event
->
event_id
;
e
.
priority
=
event
->
priority
;
e
.
flags
=
event
->
flags
;
e
.
owner
=
event
->
owner
;
e
.
subclass_name
=
event
->
subclass_name
;
e
.
body
=
event
->
body
;
tn
=
tpl_map
(
SWITCH_SERIALIZED_EVENT_MAP
,
&
e
,
&
sh
);
tpl_pack
(
tn
,
0
);
for
(
eh
=
event
->
headers
;
eh
;
eh
=
eh
->
next
)
{
if
(
eh
->
idx
)
continue
;
// no arrays yet
sh
.
name
=
eh
->
name
;
sh
.
value
=
eh
->
value
;
tpl_pack
(
tn
,
1
);
}
if
(
*
len
>
0
)
{
how
|=
TPL_PREALLOCD
;
}
tpl_dump
(
tn
,
how
,
data
,
len
);
tpl_free
(
tn
);
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_event_serialize
(
switch_event_t
*
event
,
char
**
str
,
switch_bool_t
encode
)
{
switch_size_t
len
=
0
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论