Skip to content

Commit 7e244bd

Browse files
andrewgithubandrewgithub
andrewgithub
authored and
andrewgithub
committed
增加websocket的客户端和服务器端代码
1 parent 7755c5d commit 7e244bd

File tree

8 files changed

+73
-0
lines changed

8 files changed

+73
-0
lines changed

inc/dlms_bash.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
#ifndef DLMS_DLMS_BASH_H
66
#define DLMS_DLMS_BASH_H
77
#include <iostream>
8+
#include <functional>
89

910
class Plugin;
1011
class IDlms {
12+
public:
13+
typedef typename std::function<int32_t ()> Func;
14+
1115
public:
1216
virtual ~IDlms() = default;
1317

@@ -45,6 +49,11 @@ class IDlms {
4549
* @return nullptr:失败,其他:成功
4650
*/
4751
virtual Plugin *GetPlugin(std::string &pluginName) = 0;
52+
53+
// 将需要工作的线程放到Push里面
54+
virtual uint32_t PushWork(Func workFunction) = 0;
55+
// 如果某些函数不需要再执行了就Pop掉,之后主框架就不在执行该函数了
56+
virtual int32_t PopWork(uint32_t Index) = 0;
4857
};
4958

5059

inc/plugin.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ class Plugin {
7373
std::string handleName; // name of the plugin
7474
};
7575

76+
#ifdef __cplusplus
77+
extern "C" {
78+
const char* GetVersion();
79+
Plugin *CreatePlugin(const char* pluginName);
80+
}
81+
82+
#endif
7683

7784

7885

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//
2+
// Created by wangyz38535 on 2022/6/28.
3+
//
4+
5+
#include "websocket_client.h"

plugins/websocket/websocket_client.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Created by wangyz38535 on 2022/6/28.
3+
//
4+
5+
#ifndef DLMS_WEBSOCKET_CLIENT_H
6+
#define DLMS_WEBSOCKET_CLIENT_H
7+
8+
9+
class websocket_client {
10+
11+
};
12+
13+
14+
#endif //DLMS_WEBSOCKET_CLIENT_H
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//
2+
// Created by wangyz38535 on 2022/6/28.
3+
//
4+
5+
#include "websocket_plugin.h"

plugins/websocket/websocket_plugin.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Created by wangyz38535 on 2022/6/28.
3+
//
4+
5+
#ifndef DLMS_WEBSOCKET_PLUGIN_H
6+
#define DLMS_WEBSOCKET_PLUGIN_H
7+
8+
9+
class websocket_plugin {
10+
11+
};
12+
13+
14+
#endif //DLMS_WEBSOCKET_PLUGIN_H
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//
2+
// Created by wangyz38535 on 2022/6/28.
3+
//
4+
5+
#include "websocket_server.h"

plugins/websocket/websocket_server.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Created by wangyz38535 on 2022/6/28.
3+
//
4+
5+
#ifndef DLMS_WEBSOCKET_SERVER_H
6+
#define DLMS_WEBSOCKET_SERVER_H
7+
8+
9+
class websocket_server {
10+
11+
};
12+
13+
14+
#endif //DLMS_WEBSOCKET_SERVER_H

0 commit comments

Comments
 (0)