コード例 #1
0
ファイル: roster.cpp プロジェクト: AsamQi/libsourcey
void Roster::update(const json::Value& data, bool whiny)
{
	if (data.isObject() &&
		data.isMember("id") && 
		data.isMember("user") && 
		data.isMember("name") //&& 
		//data.isMember("type")
		) {
		TraceLS(this) << "Updating: " << json::stringify(data, true) << endl;
		std::string id = data["id"].asString();
		Peer* peer = get(id, false);
		if (!peer) {
			peer = new Peer(data);
			add(id, peer);
		} else
			static_cast<json::Value&>(*peer) = data;
	}
	else if (data.isArray()) {
		for (auto it = data.begin(); it != data.end(); it++) {
			update(*it, whiny);	
		}
	}
	else {
		std::string error("Bad presence data: " + json::stringify(data));
		ErrorLS(this) << error << endl;	
		if (whiny)
			throw std::runtime_error(error);
	}
}
コード例 #2
0
ファイル: audiocapture.cpp プロジェクト: runt18/libsourcey
void AudioCapture::setError(const std::string& message, bool throwExec)
{
    ErrorLS(this) << "Error: " << message << endl;
    _error = message;
    if (throwExec)
        throw std::runtime_error(message);
}
コード例 #3
0
ファイル: tcpsocket.cpp プロジェクト: runt18/libsourcey
void TCPSocket::onAcceptConnection(uv_stream_t*, int status) 
{        
    if (status == 0) {
        TraceLS(this) << "On accept connection" << endl;
        acceptConnection();
    }
    else
        ErrorLS(this) << "Accept connection failed" << endl;
}
コード例 #4
0
bool TCPConnectionPair::doPeerConnect(const net::Address& peerAddr)
{	
	try {
		assert(!transactionID.empty());
		peer = std::make_shared<net::TCPSocket>();
		peer->opaque = this;
		peer->Close += sdelegate(this, &TCPConnectionPair::onConnectionClosed);

		// Start receiving early media
		peer->Recv += sdelegate(this, &TCPConnectionPair::onPeerDataReceived);

		// Connect request specific events
		peer->Connect += sdelegate(this, &TCPConnectionPair::onPeerConnectSuccess);
		peer->Error += sdelegate(this, &TCPConnectionPair::onPeerConnectError);
	
		client->connect(peerAddr);
	} 
	catch (std::exception& exc) {
		ErrorLS(this) << "Peer connect error: " << exc.what() << endl;
		assert(0);
		return false;
	}
	return true;
}