本文整理汇总了C++中session_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ session_ptr类的具体用法?C++ session_ptr怎么用?C++ session_ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了session_ptr类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: on_async_response_received
virtual void on_async_response_received(
error_code const & ec,
size_t bytes_transferred,
session_ptr sess
)
{
std::cout << ec << " Response received: (" << bytes_transferred << ") ";
sess->dump_buffer(bytes_transferred);
std::cout << std::endl;
if(!ec)
{
if(sess->data_buffer[1] == 0x5a)
{
sess->handler(error_code());
}
else
{
sess->handler(error_code(boost::asio::error::connection_refused));
}
}
else
{
sess->handler(ec);
}
}
开发者ID:houzhenggang,项目名称:libnetpp,代码行数:26,代码来源:socks4.hpp
示例2: handle_accept
void handle_accept(session_ptr new_session,
const asio::error_code& error)
{
if (!error)
{
new_session->start();
new_session.reset(new session(io_service_));
acceptor_.async_accept(new_session->socket(),
boost::bind(&server::handle_accept, this, new_session,
asio::placeholders::error));
}
}
开发者ID:HunterChen,项目名称:hanb-boost-asio-sample,代码行数:12,代码来源:reference_counted.cpp
示例3: session_created
void session_created( session_ptr session ) {
if( ! session ) {
LOG( "error, not connected." );
return ;
}
session_handler_ptr handler(new udp_session_handler());
session->set_handler( handler );
session->get_filter_chain()->session_connected( session );
client = session;
}
开发者ID:jerky168,项目名称:fastnetwork,代码行数:12,代码来源:client.cpp
示例4: handle_accept
void handle_accept(session_ptr new_session,
const boost::system::error_code& error)
{
if (!error)
{
new_session->start();
new_session.reset(new session(io_service_work_pool_.get_io_service(), io_service_pool_.get_io_service()));
acceptor_.async_accept(new_session->socket(),
boost::bind(&server::handle_accept, this, new_session,
boost::asio::placeholders::error));
}
}
开发者ID:bonly,项目名称:exercise,代码行数:12,代码来源:20100109_asio_post.cpp
示例5: on_async_request_sent
virtual void on_async_request_sent(
error_code const & ec,
session_ptr sess
)
{
if(!ec)
{
boost::asio::async_read(
sess->socket.get(),
boost::asio::buffer(sess->data_buffer),
boost::asio::transfer_at_least(8),
boost::bind(
&socks4_proxy::on_async_response_received,
this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred,
sess
)
);
}
else
{
sess->handler(ec);
}
}
开发者ID:houzhenggang,项目名称:libnetpp,代码行数:25,代码来源:socks4.hpp
示例6: insert
/// 插入
void insert(session_ptr sp)
{
if (!sp) return ;
BOOST_INTERLOCKED_INCREMENT(&size_);
typename lock_type::scoped_lock lock(lock_);
list_.push_back(sp.get());
}
开发者ID:hyg19831230,项目名称:Bex,代码行数:9,代码来源:session_list_mgr.hpp
示例7: new_session
void Connection::handle_accept(session_ptr session, const boost::system::error_code& error)
{
if (!error)
{
session->start();
session_ptr new_session(new Session(io_service_, room_));
acceptor_.async_accept(new_session->socket(), boost::bind(&Connection::handle_accept, this, new_session, boost::asio::placeholders::error));
}
}
开发者ID:zgangbincan,项目名称:boost,代码行数:9,代码来源:Connection.cpp
示例8: lock
void server::handle_accept(session_ptr new_session,
const boost::system::error_code& error)
{
if (!error)
{
{
boost::mutex::scoped_lock lock(sessionsLock_);
sessions_.push_back(new_session);
session_ptr new_session(new session(io_service_, this, maxLength_));
acceptor_.async_accept(new_session->socket(),
boost::bind(&server::handle_accept, this, new_session,
boost::asio::placeholders::error));
}
new_session->start();
}
start_accept();
}
开发者ID:aqyblitz,项目名称:basic-components,代码行数:18,代码来源:BoostServer.cpp
示例9: handle_read
void handle_read(const session_ptr& the_session,
handler_allocator_type& the_allocator,
const frame_buffer_ptr& frame_buffer,
const boost::system::error_code& error,
std::size_t frames_transferred)
{
print_frames(*frame_buffer, frames_transferred);
if (boost::asio::error::eof == error)
{
std::cout << "Input stream was closed." \
" But it\'s a serial port so begin read operation again...\n";
the_session->async_read_some(frame_buffer->begin(), frame_buffer->end(),
ma::make_custom_alloc_handler(the_allocator, ma::detail::bind(
handle_read, the_session, ma::detail::ref(the_allocator),
frame_buffer, ma::detail::placeholders::_1,
ma::detail::placeholders::_2)));
return;
}
if (error)
{
std::cout << "Read unsuccessful. Begin the session stop...\n";
the_session->async_stop(ma::make_custom_alloc_handler(the_allocator,
ma::detail::bind(handle_stop, ma::detail::placeholders::_1)));
return;
}
the_session->async_read_some(frame_buffer->begin(), frame_buffer->end(),
ma::make_custom_alloc_handler(the_allocator, ma::detail::bind(handle_read,
the_session, ma::detail::ref(the_allocator), frame_buffer,
ma::detail::placeholders::_1, ma::detail::placeholders::_2)));
// Only for test of cyclic_read_session::async_write_some
//frame_ptr frame = *(frame_buffer->begin());
//the_session->async_write_some(boost::asio::buffer(*frame),
// ma::detail::bind(handle_write, the_session, frame,
// ma::detail::placeholders::_1, ma::detail::placeholders::_2));
}
开发者ID:CCJY,项目名称:asio_samples,代码行数:40,代码来源:main.cpp
示例10: handle_accept
void handle_accept(session_ptr new_session,
const boost::system::error_code& error)
{
if(!error)
{
cout << "accept connection ..." << endl;
new_session->start();
do_accept();
}
else
{
delete new_session;
}
}
开发者ID:MindFy,项目名称:yynetsdk,代码行数:14,代码来源:echosvr.cpp
示例11: handle_accept
void handle_accept(session_ptr new_session,
const boost::system::error_code & error)
{
if (!error)
{
std::cout << "New connection accepted" << std::endl;
new_session->start();
start_accept();
}
else if (error != boost::asio::error::operation_aborted)
{
// 'operation_aborted' error occurs on server stoppage
handle_error(error);
}
}
开发者ID:mrZreat,项目名称:AsioTest,代码行数:15,代码来源:echo_server.cpp
示例12: join
void server::join(const session_ptr& _user, user_id_type& uid)
{
if (closing)
return;
std::lock_guard<std::mutex> lock(session_mutex);
user_id_type newID = nextID;
nextID++;
sessions.emplace(newID, _user);
uid = newID;
misc_iosrv.post([this, newID, _user]() {
try { on_join(newID, _user->get_key()); }
catch (std::exception &ex) { on_exception(ex); }
catch (...) {}
});
}
开发者ID:xy12423,项目名称:messenger,代码行数:16,代码来源:session_server.cpp
示例13: handle_start
void handle_start(const session_ptr& the_session,
handler_allocator_type& the_allocator,
const frame_buffer_ptr& frame_buffer,
const boost::system::error_code& error)
{
if (error)
{
std::cout << "Start unsuccessful. The error is: "
<< error.message() << '\n';
return;
}
std::cout << "Session started successfully. Begin read...\n";
the_session->async_read_some(frame_buffer->begin(), frame_buffer->end(),
ma::make_custom_alloc_handler(the_allocator, boost::bind(handle_read,
the_session, boost::ref(the_allocator), frame_buffer, _1, _2)));
}
开发者ID:HunterChen,项目名称:asio-samples,代码行数:18,代码来源:main.cpp
示例14: run_script
void run_script( session_ptr session, std::string fileName, mission_id inMissionID )
{
user_session_ptr loginInfo = session->find_sessiondata<user_session>(USER_SESSION_DATA_ID);
if( !loginInfo || (loginInfo->my_user_flags() & USER_FLAG_SERVER_OWNER) == 0 )
{
session->printf( "/!not_permitted\r\n" );
return;
}
if( fileName.size() == 0 || fileName.find("..") != std::string::npos )
{
session->printf( "/!no_such_file\r\n" );
return;
}
std::string filePath( sSettingsFolderPath );
filePath.append( "/scripts/" );
filePath.append( fileName );
filePath.append( ".lua" );
// ===== LUA CODE START: =====
lua_State *L = luaL_newstate(); // Create a context.
luaL_openlibs(L); // Load Lua standard library.
// Load the file:
int s = luaL_loadfile( L, filePath.c_str() );
if( s == 0 )
{
// Run it, with 0 params, accepting an arbitrary number of return values.
// Last 0 is error handler Lua function's stack index, or 0 to ignore.
s = lua_pcall(L, 0, LUA_MULTRET, 0); // Create all the functions and objects.
}
// Create a C-backed Lua object:
lua_newtable( L ); // Create a new object & push it on the stack.
lua_newtable( L ); // Create a new 'mission' object & push it on the stack.
lua_pushlightuserdata( L, &session ); // session object in case we need it.
lua_pushinteger( L, inMissionID ); // mission ID.
lua_pushcclosure( L, mission_add_objective, 2 );// Create the method.
lua_setfield( L, -2, "add_objective" ); // Attach it to the object with a name.
lua_pushlightuserdata( L, &session ); // session object in case we need it.
lua_pushcclosure( L, mission_load, 1 );// Create the method.
lua_setfield( L, -2, "load" ); // Attach it to the object with a name.
lua_setglobal( L, "mission" ); // Register the object as name "mission".
if( s == 0 )
{
lua_getglobal(L,"main"); // Push the function we want to call.
s = lua_pcall(L, 0, LUA_MULTRET, 0);
}
// Was an error? Get error message off the stack and send it back:
if( s != 0 )
{
session->printf( "/!script_error %s\r\n", lua_tostring(L, -1) );
lua_pop(L, 1); // remove error message
}
else
session->printf( "/ran_script\r\n" ); // Send back indication of success.
lua_close(L); // Dispose of the script context.
// ===== LUA CODE END. =====
}
开发者ID:uliwitness,项目名称:interconnectgame,代码行数:65,代码来源:interconnect_scripts.cpp
示例15: handle_console_close
void handle_console_close(const session_ptr& session)
{
std::cout << "User console close detected. Begin stop the session...\n";
session->async_stop(boost::bind(handle_stop, _1));
}
开发者ID:HunterChen,项目名称:asio-samples,代码行数:5,代码来源:main.cpp
示例16: handle_console_close
void handle_console_close(const session_ptr& session)
{
std::cout << "User console close detected. Begin stop the session...\n";
session->async_stop(
ma::detail::bind(handle_stop, ma::detail::placeholders::_1));
}
开发者ID:CCJY,项目名称:asio_samples,代码行数:6,代码来源:main.cpp
注:本文中的session_ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论