MCPcopy Create free account
hub / github.com/deskflow/deskflow / handleHello

Method handleHello

src/lib/client/Client.cpp:570–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568}
569
570void Client::handleHello()
571{
572 int16_t serverMajor;
573 int16_t serverMinor;
574
575 // as luck would have it, both "Synergy" and "Barrier" are 7 chars,
576 // so we eat 7 chars and then test for either protocol name.
577 // we cannot re-use `readf` to check for various hello messages,
578 // as `readf` eats bytes (advances the stream position reference).
579 std::string protocolName;
580 ProtocolUtil::readf(m_stream, kMsgHello, &protocolName, &serverMajor, &serverMinor);
581
582 if (const auto proto = networkProtocolFromString(QString::fromStdString(protocolName));
583 proto == NetworkProtocol::Unknown) {
584 LOG_WARN("hello back received with protocol: '%s'", protocolName.c_str());
585 sendConnectionFailedEvent("got invalid hello message from server");
586 cleanupTimer();
587 cleanupConnection();
588 return;
589 }
590
591 LOG_DEBUG(
592 "saying hello back with version %s %d.%d", protocolName.c_str(), kProtocolMajorVersion, kProtocolMinorVersion
593 );
594
595 // dynamically build write format for hello back since `ProtocolUtil::writef`
596 // doesn't support formatting fixed length strings yet.
597 std::string helloBackMessage = protocolName + kMsgHelloBackArgs;
598 ProtocolUtil::writef(m_stream, helloBackMessage.c_str(), kProtocolMajorVersion, kProtocolMinorVersion, &m_name);
599
600 // now connected but waiting to complete handshake
601 setupScreen();
602 cleanupTimer();
603
604 // make sure we process any remaining messages later. we won't
605 // receive another event for already pending messages so we fake
606 // one.
607 if (m_stream->isReady()) {
608 m_events->addEvent(Event(EventTypes::StreamInputReady, m_stream->getEventTarget()));
609 }
610}
611
612void Client::handleSuspend()
613{

Callers

nothing calls this directly

Calls 5

EventClass · 0.70
isReadyMethod · 0.45
addEventMethod · 0.45
getEventTargetMethod · 0.45

Tested by

no test coverage detected