void rpc_client_session_send(rpc_session_ptr client_session) { message_ex* msg = message_ex::create_request(RPC_TEST_NETPROVIDER, 0, 0); char *buffer = new char[128]; memset(buffer, 0, 128); strcpy(buffer, "hello world"); ::dsn::marshall(msg, std::string(buffer)); wait_flag = 0; rpc_response_task* t = new rpc_response_task(msg, response_handler, buffer, nullptr); client_session->net().engine()->matcher()->on_call(msg, t); client_session->send_message(msg); wait_response(); delete []buffer; }
void connection_oriented_network::on_client_session_disconnected(rpc_session_ptr& s) { int scount; bool r = false; { utils::auto_write_lock l(_clients_lock); auto it = _clients.find(s->remote_address()); if (it != _clients.end() && it->second.get() == s.get()) { _clients.erase(it); r = true; } scount = (int)_clients.size(); } if (r) { ddebug("client session %s disconnected (%d in total)", s->remote_address().to_string(), scount); } }
void connection_oriented_network::on_server_session_accepted(rpc_session_ptr& s) { int scount = 0; { utils::auto_write_lock l(_servers_lock); auto pr = _servers.insert(server_sessions::value_type(s->remote_address(), s)); if (pr.second) { // nothing to do } else { pr.first->second = s; dwarn("server session on %s already exists, preempted", s->remote_address().to_string()); } scount = (int)_servers.size(); } ddebug("server session %s accepted (%d in total)", s->remote_address().to_string(), scount); }
void connection_oriented_network::on_client_session_connected(rpc_session_ptr& s) { int scount = 0; bool r = false; { utils::auto_read_lock l(_clients_lock); auto it = _clients.find(s->remote_address()); if (it != _clients.end() && it->second.get() == s.get()) { r = true; } scount = (int)_clients.size(); } if (r) { ddebug("client session connected, remote_server = %s, current_count = %d", s->remote_address().to_string(), scount); } }