当前位置: 首页>>代码示例>>C++>>正文


C++ message::data方法代码示例

本文整理汇总了C++中message::data方法的典型用法代码示例。如果您正苦于以下问题:C++ message::data方法的具体用法?C++ message::data怎么用?C++ message::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在message的用法示例。


在下文中一共展示了message::data方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read_header

void message_handler::read_header() {
  memset(read_msg_.data(), '\0', read_msg_.length());
  boost::asio::async_read(socket_,
      boost::asio::buffer(read_msg_.data(), message::header_size_),
      [this](boost::system::error_code ec, std::size_t) {
        if (!ec && read_msg_.decode_header()) { 
          read_body();
        } else {
            std::cout << "Error Reading message body " << ec << std::endl;
            //TODO Update the remove handler from list at EOF of disconnect
            ob.update_observer(client_id);
        }
      }
  );
}
开发者ID:lyz4534,项目名称:ipc_sockets_boost,代码行数:15,代码来源:IPC_directory.cpp

示例2: ClientClose

void GateModule::ClientClose(const message& msg)
{
	buffer_reader buf(msg.data(), msg.size());

	std::string addr;
	buf >> addr;

	Log.trace("1.client close [socketid:{0}] [address:{1}] begin.", msg.get_socket_id().value, addr.data());
	auto pconn = m_Connections->find(msg.get_socket_id());
	if (pconn == nullptr)
	{
		Log.trace("!!client close failed can not find conn [socketid:{0}].", msg.get_socket_id().value);
		return;
	}

	auto accountID = pconn->getaccount_id();
	auto playerID = pconn->getplayer_id();

	Log.trace("3.client close [socketid:{0}] [address:{1}] find account data[accountid:{2}]  success[playerid:{3}].", msg.get_socket_id().value, addr.data(), accountID.value,playerID.value);
	
	OnClientClose(accountID, playerID);
	
	if (m_Connections->remove(msg.get_socket_id()))
	{
		Log.trace("client close [socketid:{0}] [address:{1}]  accountID[{2}] playerID[{3}] end.", msg.get_socket_id().value, addr.data(), accountID.value, playerID.value);
	}
	else
	{
		assert(0);
	}
}
开发者ID:dr520,项目名称:moon_net,代码行数:31,代码来源:GateModule.cpp

示例3: read_handler

void AdminClient::read_handler(const boost::system::error_code& error, std::size_t bytes) {
    std::cout << "Recieved " << bytes << " bytes.\n";

    // The extra parens around the first argument here are necessary 
    // to avoid g++ interpreting this as a function declaration
    //std::string s((std::istreambuf_iterator<char>(&read_buffer_)), std::istreambuf_iterator<char>());

    if (error == boost::asio::error::eof)
        close();
    else if (error == boost::asio::error::operation_aborted)
        return;
    else if (error){
        std::cout << "Throwing an error.\n";
        throw boost::system::system_error(error); // Some other error.
    }

    std::string s(read_message_.data(bytes));
    std::cout << "Built string.\n";

    read_message_.consume(bytes);
    std::cout << read_message_.buffer().size() << " bytes remaining in buffer.\n";

    std::cout << s << "-----------------------\n";

    boost::system::error_code err;
    boost::asio::async_read_until(sock_, read_message_.buffer(), '\n', 
        boost::bind(&AdminClient::read_handler, this, 
            boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
开发者ID:nobody,项目名称:magiclegoblimps,代码行数:29,代码来源:AdminClient.cpp

示例4: ClientConnect

void GateModule::ClientConnect(const message& msg)
{
	buffer_reader buf(msg.data(), msg.size());

	std::string addr;
	buf >> addr;
	Log.trace("socket [socket:{0}] [address:{1}] connect", msg.get_socket_id().value,addr.data());
}
开发者ID:dr520,项目名称:moon_net,代码行数:8,代码来源:GateModule.cpp

示例5: mapi_exception

attachment::attachment(message& mapi_message, const uint32_t attach_num) throw(mapi_exception)
: object(mapi_message.get_session(), "attachment"), m_attach_num(attach_num), m_bin_data(NULL), m_data_size(0), m_filename("")
{
	if (OpenAttach(&mapi_message.data(), attach_num, &m_object) != MAPI_E_SUCCESS)
		throw mapi_exception(GetLastError(), "attachment::attachment : OpenAttach");

	property_container properties = get_property_container();
	properties << PR_ATTACH_FILENAME << PR_ATTACH_LONG_FILENAME << PR_ATTACH_SIZE << PR_ATTACH_DATA_BIN << PR_ATTACH_METHOD;
	properties.fetch();

	const char* filename = static_cast<const char*>(properties[PR_ATTACH_LONG_FILENAME]);
	if (!filename) {
		filename = static_cast<const char*>(properties[PR_ATTACH_FILENAME]);
	}

	if (filename)
		m_filename = filename;

	m_data_size = *(static_cast<const uint32_t*>(properties[PR_ATTACH_SIZE]));

	const Binary_r* attachment_data = static_cast<const Binary_r*>(properties[PR_ATTACH_DATA_BIN]);

	// Don't load PR_ATTACH_DATA_BIN if it's embedded in message.
	// NOTE: Use RopOpenEmbeddedMessage when it is implemented.
	const uint32_t attach_method = *static_cast<const uint32_t*>(properties[PR_ATTACH_METHOD]);
	if (attach_method != ATTACH_BY_VALUE)
		return;

	// Get Binary Data.
	if (attachment_data) {
		m_data_size = attachment_data->cb;
		m_bin_data = new uint8_t[m_data_size];
		memcpy(m_bin_data, attachment_data->lpb, attachment_data->cb);
	} else {
		mapi_object_t obj_stream;
		mapi_object_init(&obj_stream);
		if (OpenStream(&m_object, (enum MAPITAGS)PidTagAttachDataBinary, OpenStream_ReadOnly, &obj_stream) != MAPI_E_SUCCESS)
			throw mapi_exception(GetLastError(), "attachment::attachment : OpenStream");

		if (GetStreamSize(&obj_stream, &m_data_size) != MAPI_E_SUCCESS)
			throw mapi_exception(GetLastError(), "attachment::attachment : GetStreamSize");

		m_bin_data = new uint8_t[m_data_size];

		uint32_t pos = 0;
		uint16_t bytes_read = 0;
		do {
			if (ReadStream(&obj_stream, m_bin_data+pos, 1024, &bytes_read) != MAPI_E_SUCCESS)
				throw mapi_exception(GetLastError(), "attachment::attachment : ReadStream");

			pos += bytes_read;

		} while (bytes_read && pos < m_data_size);

		mapi_object_release(&obj_stream);
	}
}
开发者ID:EasyLinux,项目名称:Openchange,代码行数:57,代码来源:attachment.cpp

示例6: ClientData

//客户端发来的数据
void GateModule::ClientData(const message& msg)
{
	if (msg.size() == 0)
		return;

	user_id id(account_id::create(0));
	id.set_socket_id(msg.get_socket_id());

	if (DispatchMessages(id,msg,0))
	{
		return;
	}
	
	auto pconn = m_Connections->find(msg.get_socket_id());
	if (pconn == nullptr)
	{
		Log.trace("非法数据!");
		return;
	}


	uint16_t msgID = *(uint16_t*)msg.data();
	if (msgID > (uint16_t)EMsgID::MSG_MUST_HAVE_PLAYERID)
	{
		if (pconn->getplayer_id() == player_id())
		{
			Log.trace("非法数据!");
			return;
		}
	}

	UserContext ctx;
	ctx.accountid = pconn->getaccount_id();
	ctx.playerid = pconn->getplayer_id();

	msg.set_userdata((uint8_t*)&ctx,sizeof(ctx));

	if (pconn->getscene_id() != 0)
	{
		//如果在玩家在场景模块中 则发送给场景模块
	}
	else
	{
		if (m_WorldModule == 0)
		{
			m_WorldModule = GetOtherModule("world");
			assert(m_WorldModule != 0);
		}

		//否则发送给 world 模块
	}
}
开发者ID:dr520,项目名称:moon_net,代码行数:53,代码来源:GateModule.cpp

示例7: validate

// NOTE: the format of this response changed in v3 (send only code on error).
void transaction_pool::validate(server_node& node, const message& request,
    send_handler handler)
{
    transaction tx;

    if (!tx.from_data(request.data()))
    {
        handler(message(request, error::bad_stream));
        return;
    }

    node.pool().validate(tx,
        std::bind(&transaction_pool::handle_validated,
            _1, _2, _3, _4, request, handler));
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-server,代码行数:16,代码来源:transaction_pool.cpp

示例8: broadcast

// Broadcast a transaction with penetration subscription.
void transaction_pool::broadcast(server_node& node, const message& request,
    send_handler handler)
{
    transaction tx;

    if (!tx.from_data(request.data()))
    {
        handler(message(request, error::bad_stream));
        return;
    }

    // TODO: conditionally subscribe to penetration notifications.
    // TODO: broadcast transaction to receiving peers.
    handler(message(request, error::operation_failed));
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-server,代码行数:16,代码来源:transaction_pool.cpp

示例9: unwrap_fetch_transaction_args

bool unwrap_fetch_transaction_args(hash_digest& hash,
    const message& request)
{
    const auto& data = request.data();

    if (data.size() != hash_size)
    {
        log::error(LOG_SERVER)
            << "Invalid hash length in fetch_transaction request.";
        return false;
    }

    auto deserial = make_deserializer(data.begin(), data.end());
    hash = deserial.read_hash();
    return true;
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-server,代码行数:16,代码来源:fetch_helpers.cpp

示例10: DispatchMessages

bool ModuleBases::DispatchMessages(const user_id & userid, const message & msg, uint64_t sender_echo_id)
{
	buffer_reader br(msg.data(), msg.size());

	uint16_t msgID = 0;
	br >> msgID;

	if (msgID == uint16_t(EMsgID::MSG_S2S_ClientClose))
	{
		account_id accountID;
		player_id playerID;
		br >> accountID.value;
		br >> playerID.value;
		OnClientClose(accountID, playerID);
		return true;
	}
开发者ID:dr520,项目名称:moon_net,代码行数:16,代码来源:ModuleBases.cpp

示例11: unwrap_fetch_history_args

bool unwrap_fetch_history_args(payment_address& address,
    uint32_t& from_height, const message& request)
{
    static constexpr size_t history_args_size = sizeof(uint8_t) +
        short_hash_size + sizeof(uint32_t);

    const auto& data = request.data();

    if (data.size() != history_args_size)
    {
        log::error(LOG_SERVER)
            << "Incorrect data size for .fetch_history";
        return false;
    }

    auto deserial = make_deserializer(data.begin(), data.end());
    const auto version_byte = deserial.read_byte();
    const auto hash = deserial.read_short_hash();
    from_height = deserial.read_4_bytes_little_endian();
    BITCOIN_ASSERT(deserial.iterator() == data.end());

    address = payment_address(hash, version_byte);
    return true;
}
开发者ID:RojavaCrypto,项目名称:libbitcoin-server,代码行数:24,代码来源:fetch_helpers.cpp

示例12: read_data_callback

void client_socket_utils::read_data_callback(const boost::system::error_code& e, socket_session_ptr session, message& msg)
{
	LOG4CXX_DEBUG(firebird_log, "command =[" << msg.command << "],[" << msg.business_type << "],[" << msg.data() << "]");

	if (msg.command == heartbeat)
	{ //心跳
	}
	else
		if (msg.command == regist)
		{ //注册
			LOG4CXX_FATAL(firebird_log, "服务器:[" << session->get_business_type() << "]注册成功。");
		}
		else
			if (msg.command == normal)
			{ //业务数据
				handle_read_data(msg, session);
			}
			else
			{
				LOG4CXX_ERROR(firebird_log, KDS_CODE_INFO << "收到非法消息包!");
			}
}
开发者ID:piaoyimq,项目名称:CppSpace,代码行数:22,代码来源:client_socket_utils.cpp

示例13:

	message(message& other) : _data(NULL) {
		body_reset(other.length_body());
		data()[0] = other.data()[0]; //copy header
		if (length_body() > 0)
			memcpy(data(), other.data(), length_body());
	}
开发者ID:182826136,项目名称:primecoin,代码行数:6,代码来源:primeminer_conx.hpp


注:本文中的message::data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。