コード例 #1
0
ファイル: gatekeeper.cpp プロジェクト: Mogito89/TOX002
void Gatekeeper::Handle()
{
	std::stringstream r(message_);
	std::string s;

	r >> s;

	if( iequals( s, "GIV" ) )
	{
		std::getline(r, s);
		const std::size_t pos = s.find(':');
		std::string hex = s.substr(pos + 1, 2 * 16);
		GUID guid;
		assert(hex.size() == 32);
		Conv::Hex::Decode(hex.begin(), hex.end(), guid.begin());

		std::vector< DownloadPtr > v;
		System::GetDownloadMgr()->Dump(std::back_inserter(v));
		for(uint i = 0; i < v.size(); ++i)
			if(v[i]->HandleGIV(this, guid)) 
				break;
		return;
	}
	else if(iequals(s, "GET"))
	{
		if(message_.find("\r\n\r\n") == std::string::npos)
			throw MessageIncomplete();
		System::GetUploadMgr()->Accept(this);
	}
	else
		throw std::runtime_error("Unhandled");

}
コード例 #2
0
ファイル: gatekeeper.cpp プロジェクト: Mogito89/TOX002
void Gatekeeper::OnConnected(const bs::error_code& err)
{
	if(closed_) return;

	if(!err) 
	{
		System::LogBas() << "Connected by push to " << endpoint_ << std::endl;
		std::string greet = "GIV 0:";
		const GUID guid = System::Guid();
		Conv::Hex::Encode(guid.begin(), guid.end(), std::back_inserter(greet));
		greet += "/\r\n";
		buffer_.assign(greet.begin(), greet.end());
		ba::async_write(*pSock_, ba::buffer(buffer_), boost::bind(&Gatekeeper::OnGreetingSent, shared_from_this(), _1));
	}
	else if(err != ba::error::operation_aborted)
	{
		System::LogDev() << "Gatekeeper::OnConnected " << endpoint_ << " error => " << err.message() << std::endl;
		DetachMe();
	}
}
コード例 #3
0
ファイル: guid.cpp プロジェクト: jralls/gnucash
bool operator == (GUID const & lhs, GncGUID const & rhs) noexcept
{
    auto ret = std::mismatch (lhs.begin (), lhs.end (), rhs.reserved);
    return ret.first == lhs.end ();

}