Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
youngwolf
ascs
提交
a31678bb
A
ascs
项目概览
youngwolf
/
ascs
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ascs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a31678bb
编写于
7月 09, 2020
作者:
Y
youngwolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Release ascs::socket's function void id(uint_fast64_t id) for single client (both tcp and udp).
上级
6c5269cb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
2 deletion
+10
-2
examples/unix_socket/unix_socket.cpp
examples/unix_socket/unix_socket.cpp
+5
-0
include/ascs/socket.h
include/ascs/socket.h
+2
-1
include/ascs/socket_service.h
include/ascs/socket_service.h
+3
-1
未找到文件。
examples/unix_socket/unix_socket.cpp
浏览文件 @
a31678bb
...
...
@@ -26,6 +26,11 @@ int main(int argc, const char* argv[])
server
.
set_server_addr
(
UNIX_SOCKET_NAME
);
client
.
set_server_addr
(
UNIX_SOCKET_NAME
);
//demonstrate how to set/get single client's id, and how to set/get i_service's id.
//we need specific conversion for i_service because it has the same function name as single client does.
client
.
id
(
10000
);
std
::
cout
<<
client
.
id
()
<<
" : "
<<
((
service_pump
::
i_service
&
)
client
).
id
()
<<
std
::
endl
;
sp
.
start_service
();
while
(
sp
.
is_running
())
{
...
...
include/ascs/socket.h
浏览文件 @
a31678bb
...
...
@@ -566,7 +566,8 @@ private:
//please do not change id at runtime via the following function, except this socket is not managed by object_pool,
//it should only be used by object_pool when reusing or creating new socket.
template
<
typename
Object
>
friend
class
object_pool
;
template
<
typename
>
friend
class
object_pool
;
template
<
typename
>
friend
class
single_socket_service
;
void
id
(
uint_fast64_t
id
)
{
_id
=
id
;}
#ifdef ASCS_SYNC_RECV
...
...
include/ascs/socket_service.h
浏览文件 @
a31678bb
...
...
@@ -26,12 +26,14 @@ public:
single_socket_service
(
service_pump
&
service_pump_
)
:
i_service
(
service_pump_
),
Socket
(
service_pump_
)
{}
template
<
typename
Arg
>
single_socket_service
(
service_pump
&
service_pump_
,
Arg
&&
arg
)
:
i_service
(
service_pump_
),
Socket
(
service_pump_
,
std
::
forward
<
Arg
>
(
arg
))
{}
using
Socket
::
id
;
//release these functions
protected:
virtual
bool
init
()
{
this
->
start
();
return
Socket
::
started
();}
virtual
void
uninit
()
{
this
->
graceful_shutdown
();}
//if you wanna force shutdown, call force_shutdown before service_pump::stop_service invocation.
private:
using
Socket
::
get_matrix
;
using
Socket
::
get_matrix
;
//hide this function
};
template
<
typename
Socket
,
typename
Pool
,
typename
Matrix
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录