CClientProxy1_0::CClientProxy1_0(const CString& name, IStream* stream) :
	CClientProxy(name, stream),
	m_heartbeatTimer(NULL),
	m_parser(&CClientProxy1_0::parseHandshakeMessage)
{
	// install event handlers
	EVENTQUEUE->adoptHandler(IStream::getInputReadyEvent(),
							stream->getEventTarget(),
							new TMethodEventJob<CClientProxy1_0>(this,
								&CClientProxy1_0::handleData, NULL));
	EVENTQUEUE->adoptHandler(IStream::getOutputErrorEvent(),
							stream->getEventTarget(),
							new TMethodEventJob<CClientProxy1_0>(this,
								&CClientProxy1_0::handleWriteError, NULL));
	EVENTQUEUE->adoptHandler(IStream::getInputShutdownEvent(),
							stream->getEventTarget(),
							new TMethodEventJob<CClientProxy1_0>(this,
								&CClientProxy1_0::handleDisconnect, NULL));
	EVENTQUEUE->adoptHandler(IStream::getOutputShutdownEvent(),
							stream->getEventTarget(),
							new TMethodEventJob<CClientProxy1_0>(this,
								&CClientProxy1_0::handleWriteError, NULL));
	EVENTQUEUE->adoptHandler(CEvent::kTimer, this,
							new TMethodEventJob<CClientProxy1_0>(this,
								&CClientProxy1_0::handleFlatline, NULL));

	setHeartbeatRate(kHeartRate, kHeartRate * kHeartBeatsUntilDeath);

	LOG((CLOG_DEBUG1 "querying client \"%s\" info", getName().c_str()));
	CProtocolUtil::writef(getStream(), kMsgQInfo);
}
Beispiel #2
0
CClientProxy1_3::CClientProxy1_3(const CString& name, IStream* stream) :
	CClientProxy1_2(name, stream),
	m_keepAliveRate(kKeepAliveRate),
	m_keepAliveTimer(NULL)
{
	setHeartbeatRate(kKeepAliveRate, kKeepAliveRate * kKeepAlivesUntilDeath);
}
CClientProxy1_3::CClientProxy1_3(const CString& name, synergy::IStream* stream, IEventQueue* eventQueue) :
	CClientProxy1_2(name, stream, eventQueue),
	m_keepAliveRate(kKeepAliveRate),
	m_keepAliveTimer(NULL)
{
	setHeartbeatRate(kKeepAliveRate, kKeepAliveRate * kKeepAlivesUntilDeath);
}
Beispiel #4
0
ClientProxy1_0::ClientProxy1_0(const String& name, synergy::IStream* stream, IEventQueue* events) :
	ClientProxy(name, stream),
	m_heartbeatTimer(NULL),
	m_parser(&ClientProxy1_0::parseHandshakeMessage),
	m_events(events)
{
	// install event handlers
	m_events->adoptHandler(m_events->forIStream().inputReady(),
							stream->getEventTarget(),
							new TMethodEventJob<ClientProxy1_0>(this,
								&ClientProxy1_0::handleData, NULL));
	m_events->adoptHandler(m_events->forIStream().outputError(),
							stream->getEventTarget(),
							new TMethodEventJob<ClientProxy1_0>(this,
								&ClientProxy1_0::handleWriteError, NULL));
	m_events->adoptHandler(m_events->forIStream().inputShutdown(),
							stream->getEventTarget(),
							new TMethodEventJob<ClientProxy1_0>(this,
								&ClientProxy1_0::handleDisconnect, NULL));
	m_events->adoptHandler(m_events->forIStream().outputShutdown(),
							stream->getEventTarget(),
							new TMethodEventJob<ClientProxy1_0>(this,
								&ClientProxy1_0::handleWriteError, NULL));
	m_events->adoptHandler(Event::kTimer, this,
							new TMethodEventJob<ClientProxy1_0>(this,
								&ClientProxy1_0::handleFlatline, NULL));

	setHeartbeatRate(kHeartRate, kHeartRate * kHeartBeatsUntilDeath);

	LOG((CLOG_DEBUG1 "querying client \"%s\" info", getName().c_str()));
	ProtocolUtil::writef(getStream(), kMsgQInfo);
}
void
CClientProxy1_0::setOptions(const COptionsList& options)
{
	LOG((CLOG_DEBUG1 "send set options to \"%s\" size=%d", getName().c_str(), options.size()));
	CProtocolUtil::writef(getStream(), kMsgDSetOptions, &options);

	// check options
	for (UInt32 i = 0, n = (UInt32)options.size(); i < n; i += 2) {
		if (options[i] == kOptionHeartbeat) {
			double rate = 1.0e-3 * static_cast<double>(options[i + 1]);
			if (rate <= 0.0) {
				rate = -1.0;
			}
			setHeartbeatRate(rate, rate * kHeartBeatsUntilDeath);
			removeHeartbeatTimer();
			addHeartbeatTimer();
		}
	}
}
void
CClientProxy1_0::resetHeartbeatRate()
{
	setHeartbeatRate(kHeartRate, kHeartRate * kHeartBeatsUntilDeath);
}
Beispiel #7
0
void
CClientProxy1_3::resetHeartbeatRate()
{
	setHeartbeatRate(kKeepAliveRate, kKeepAliveRate * kKeepAlivesUntilDeath);
}