2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
|
|
|
|
#include "../stream/aio_listen_stream.hpp"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
class aio_handle;
|
|
|
|
|
class aio_listen_stream;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>첽<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
class ACL_CPP_API ipc_server : private aio_accept_callback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ipc_server();
|
|
|
|
|
|
|
|
|
|
virtual ~ipc_server();
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param handle {aio_handle*} <EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD>
|
|
|
|
|
* @param addr {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
bool open(aio_handle* handle, const char* addr = "127.0.0.1:0");
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD> open <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
* @return {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽΪ<EFBFBD><EFBFBD> IP:PORT
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
const char* get_addr() const;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {aio_listen_stream*}
|
|
|
|
|
*/
|
|
|
|
|
aio_listen_stream* get_stream() const;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
aio_handle& get_handle() const;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param addr {const char*} ʵ<EFBFBD>ʵļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>IP:PORT
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
virtual void on_open(const char*addr)
|
|
|
|
|
{
|
|
|
|
|
(void) addr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>ʱ<EFBFBD>Ļص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
virtual void on_close() {}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><EFBFBD>Ļص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param client {aio_socket_stream*} <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD> IPC <EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
virtual void on_accept(aio_socket_stream* client)
|
|
|
|
|
{
|
|
|
|
|
(void) client;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 17:33:11 +08:00
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
2014-11-19 00:25:21 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD><EFBFBD> _WIN32 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> open ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> create_windows <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
virtual bool create_window()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
aio_handle* handle_;
|
|
|
|
|
aio_listen_stream* sstream_;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˻ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param client {aio_socket_stream*} <EFBFBD>첽<EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
virtual bool accept_callback(aio_socket_stream* client);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>ʱ<EFBFBD>Ļص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
virtual void close_callback();
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>麯<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ļص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
virtual bool timeout_callback();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|