提交 a31678bb 编写于 作者: Y youngwolf

Release ascs::socket's function void id(uint_fast64_t id) for single client (both tcp and udp).

上级 6c5269cb
......@@ -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())
{
......
......@@ -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
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册