Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colorEagleStdio
zoompipeline
提交
08ed9710
zoompipeline
项目概览
colorEagleStdio
/
zoompipeline
通知
181
Star
12
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
zoompipeline
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
08ed9710
编写于
12月 28, 2013
作者:
丁劲犇
😸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
continue building client node structures. A lot of work left to do.
上级
2e42cc0c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
90 addition
and
22 deletion
+90
-22
ZoomPipeline_FuncSvr/smartlink/st_client_table.cpp
ZoomPipeline_FuncSvr/smartlink/st_client_table.cpp
+7
-13
ZoomPipeline_FuncSvr/smartlink/st_client_table.h
ZoomPipeline_FuncSvr/smartlink/st_client_table.h
+2
-3
ZoomPipeline_FuncSvr/smartlink/st_clientnode.cpp
ZoomPipeline_FuncSvr/smartlink/st_clientnode.cpp
+40
-2
ZoomPipeline_FuncSvr/smartlink/st_clientnode.h
ZoomPipeline_FuncSvr/smartlink/st_clientnode.h
+41
-4
未找到文件。
ZoomPipeline_FuncSvr/smartlink/st_client_table.cpp
浏览文件 @
08ed9710
...
...
@@ -5,8 +5,8 @@ st_client_table::st_client_table(ZPNetwork::zp_net_ThreadPool * pool, ZPTaskEngi
,
m_pThreadPool
(
pool
)
,
m_pTaskEngine
(
taskeng
)
{
m_hash_
id2sock
=
ZPHashTable
::
hash_init
(
2
,
1
);
m_hash_sock2
id
=
ZPHashTable
::
hash_init
(
2
,
1
);
m_hash_
uuid2node
=
ZPHashTable
::
hash_init
(
2
,
1
);
m_hash_sock2
node
=
ZPHashTable
::
hash_init
(
2
,
1
);
connect
(
m_pThreadPool
,
&
ZPNetwork
::
zp_net_ThreadPool
::
evt_NewClientConnected
,
this
,
&
st_client_table
::
on_evt_NewClientConnected
);
connect
(
m_pThreadPool
,
&
ZPNetwork
::
zp_net_ThreadPool
::
evt_ClientDisconnected
,
this
,
&
st_client_table
::
on_evt_ClientDisconnected
);
connect
(
m_pThreadPool
,
&
ZPNetwork
::
zp_net_ThreadPool
::
evt_Data_recieved
,
this
,
&
st_client_table
::
on_evt_Data_recieved
);
...
...
@@ -15,19 +15,13 @@ st_client_table::st_client_table(ZPNetwork::zp_net_ThreadPool * pool, ZPTaskEngi
}
st_client_table
::~
st_client_table
()
{
ZPHashTable
::
hash_fini
(
m_hash_
id2sock
);
ZPHashTable
::
hash_fini
(
m_hash_sock2
id
);
m_hash_sock2
id
=
0
;
m_hash_
id2sock
=
0
;
ZPHashTable
::
hash_fini
(
m_hash_
uuid2node
);
ZPHashTable
::
hash_fini
(
m_hash_sock2
node
);
m_hash_sock2
node
=
0
;
m_hash_
uuid2node
=
0
;
}
unsigned
int
st_client_table
::
BKDRHash
(
const
char
*
str
)
{
register
unsigned
int
hash
=
0
;
while
(
unsigned
int
ch
=
(
unsigned
int
)
*
(
str
++
))
hash
=
hash
*
131
+
ch
;
return
hash
;
}
//this event indicates new client connected.
void
st_client_table
::
on_evt_NewClientConnected
(
QObject
*
/*clientHandle*/
)
...
...
ZoomPipeline_FuncSvr/smartlink/st_client_table.h
浏览文件 @
08ed9710
...
...
@@ -12,10 +12,9 @@ class st_client_table : public QObject
public:
explicit
st_client_table
(
ZPNetwork
::
zp_net_ThreadPool
*
pool
,
ZPTaskEngine
::
zp_pipeline
*
taskeng
,
QObject
*
parent
=
0
);
~
st_client_table
();
static
unsigned
int
BKDRHash
(
const
char
*
str
)
;
protected:
ZPHashTable
::
CDYNHASHTB
m_hash_
id2sock
;
ZPHashTable
::
CDYNHASHTB
m_hash_sock2
id
;
ZPHashTable
::
CDYNHASHTB
m_hash_
uuid2node
;
ZPHashTable
::
CDYNHASHTB
m_hash_sock2
node
;
ZPNetwork
::
zp_net_ThreadPool
*
m_pThreadPool
;
ZPTaskEngine
::
zp_pipeline
*
m_pTaskEngine
;
signals:
...
...
ZoomPipeline_FuncSvr/smartlink/st_clientnode.cpp
浏览文件 @
08ed9710
#include "st_clientnode.h"
st_clientNode
::
st_clientNode
(
QObject
*
parent
)
:
namespace
SmartLink
{
st_clientNode
::
st_clientNode
(
QObject
*
pClientSock
,
QObject
*
parent
)
:
QObject
(
parent
)
{
m_bUUIDRecieved
=
false
;
m_pClientSock
=
pClientSock
;
m_uuid
[
0
]
=
0
;
m_nUuidHashKey
=
0
;
m_nSockHashKey
=
IntegerHash
(
m_pClientSock
);
}
unsigned
int
st_clientNode
::
BKDRHash
(
const
char
*
str
)
{
register
unsigned
int
hash
=
0
;
while
(
unsigned
int
ch
=
(
unsigned
int
)
*
(
str
++
))
hash
=
hash
*
131
+
ch
;
return
hash
;
}
unsigned
int
st_clientNode
::
IntegerHash
(
void
*
ptr
)
{
register
unsigned
int
hash
=
0
;
unsigned
int
sz
=
sizeof
(
void
*
);
unsigned
int
val
=
(
unsigned
int
)
ptr
;
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
hash
=
hash
*
131
+
(
unsigned
int
)((
val
>>
(
i
*
8
))
&
0x0ff
);
return
hash
;
}
//The main functional method, will run in thread pool
int
st_clientNode
::
deal_message
(
int
nMessage
)
{
return
-
1
;
}
//push new binary data into queue
void
st_clientNode
::
push_new_data
(
const
QByteArray
&
dtarray
)
{
m_mutex
.
lock
();
m_list_RawData
.
push_back
(
dtarray
);
m_mutex
.
unlock
();
}
}
ZoomPipeline_FuncSvr/smartlink/st_clientnode.h
浏览文件 @
08ed9710
...
...
@@ -2,21 +2,58 @@
#define CLIENTNODE_H
#include <QObject>
#include <QList>
#include <QMutex>
namespace
SmartLink
{
class
st_clientNode
:
public
QObject
{
Q_OBJECT
public:
explicit
st_clientNode
(
QObject
*
parent
=
0
);
protected:
explicit
st_clientNode
(
QObject
*
pClientSock
,
QObject
*
parent
=
0
);
//The main functional method, will run in thread pool
int
deal_message
(
int
nMessage
);
//push new binary data into queue
void
push_new_data
(
const
QByteArray
&
dtarray
);
signals:
unsigned
char
*
uuid
(){
return
m_uuid
;}
QObject
*
sock
()
{
return
m_pClientSock
;}
unsigned
int
uuid_hash
()
{
return
m_nUuidHashKey
;
}
unsigned
int
sock_hash
()
{
return
m_nSockHashKey
;
}
//hash value maker
static
unsigned
int
BKDRHash
(
const
char
*
str
)
;
static
unsigned
int
IntegerHash
(
void
*
ptr
);
//data items
protected:
//uuid len, uuid is an message header, identifies a special client instument.
static
const
int
uuid_len
=
24
;
//deal at most m_nMessageBlockSize messages per deal_message();
static
const
int
m_nMessageBlockSize
=
8
;
//The raw data queue and its mutex
QList
<
QByteArray
>
m_list_RawData
;
QMutex
m_mutex
;
//UUID of this equipment
bool
m_bUUIDRecieved
;
unsigned
char
m_uuid
[
uuid_len
];
unsigned
int
m_nUuidHashKey
;
//Client socket handle of this connection
QObject
*
m_pClientSock
;
unsigned
int
m_nSockHashKey
;
protected:
public
slots
:
signals:
void
evt_SendDataToClient
(
QObject
*
objClient
,
const
QByteArray
&
dtarray
);
void
evt_BroadcastData
(
QObject
*
objFromClient
,
const
QByteArray
&
dtarray
);
};
}
#endif // CLIENTNODE_H
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录