12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /**
- * space_server 对外接口通用功能。
- *
- * © 2020 成都河狸智能科技有限责任公司。保留所有权利。
- *
- * 作者: zhq1229
- */
- #ifndef __SERVER_H__
- #define __SERVER_H__
- #include <space_lib/space_lib.h>
- namespace server {
- typedef void (*ReadCallback)(Json::Value &data, space::comm::CommMsg &msg);
- typedef void (*WritCallback)();
- enum CommType {
- COMM_NONE = 0,
- COMM_WEBSOCKET_SERVER,
- COMM_WEBSOCKET_CLIENT,
- COMM_TCP_SERVER,
- COMM_TCP_CLIENT,
- COMM_UDP,
- COMM_SERIAL,
- };
- enum WritType {
- WRIT_CALLBACK = 0,
- WRIT_JSON,
- };
- struct Comm {
- Comm() :
- type(COMM_NONE),
- ws_server(nullptr),
- ws_client(nullptr),
- tcp_server(nullptr),
- tcp_client(nullptr),
- udp(nullptr),
- serial(nullptr) { }
- CommType type;
- space::comm::WsServer *ws_server;
- space::comm::WsClient *ws_client;
- space::comm::TcpServer *tcp_server;
- space::comm::TcpClient *tcp_client;
- space::comm::Udp *udp;
- space::comm::Serial *serial;
- };
- struct Writ {
- Writ() :
- writ_callback(nullptr),
- data(Json::Value()),
- cycle(0),
- count(0),
- read_callback(nullptr),
- type(WRIT_CALLBACK) { }
- WritCallback writ_callback;
- Json::Value data;
- unsigned int cycle;
- int count;
- ReadCallback read_callback;
- WritType type;
- };
- int init(Json::Value &conf);
- int shutdown();
- } // namespace server
- #endif // __SERVER_H__
|