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

Method closeClient

src/lib/server/Server.cpp:1934–1967  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1932}
1933
1934void Server::closeClient(BaseClientProxy *client, const char *msg)
1935{
1936 assert(client != m_primaryClient);
1937 assert(msg != nullptr);
1938
1939 // send message to client. this message should cause the client
1940 // to disconnect. we add this client to the closed client list
1941 // and install a timer to remove the client if it doesn't respond
1942 // quickly enough. we also remove the client from the active
1943 // client list since we're not going to listen to it anymore.
1944 // note that this method also works on clients that are not in
1945 // the m_clients list. adoptClient() may call us with such a
1946 // client.
1947 LOG_NOTE("disconnecting client \"%s\"", getName(client).c_str());
1948
1949 // send message
1950 // FIXME -- avoid type cast (kinda hard, though)
1951 auto clientProxy = static_cast<ClientProxy *>(client);
1952 clientProxy->close(msg);
1953
1954 // install timer. wait timeout seconds for client to close.
1955 double timeout = 5.0;
1956 EventQueueTimer *timer = m_events->newOneShotTimer(timeout, nullptr);
1957 m_events->addHandler(EventTypes::Timer, timer, [this, client](const auto &) { handleClientCloseTimeout(client); });
1958
1959 // move client to closing list
1960 removeClient(client);
1961
1962 m_oldClients.insert(std::make_pair(client, timer));
1963
1964 // if this client is the active screen then we have to
1965 // jump off of it
1966 forceLeaveClient(client);
1967}
1968
1969void Server::closeClients(const ServerConfig &config)
1970{

Callers

nothing calls this directly

Calls 4

newOneShotTimerMethod · 0.80
addHandlerMethod · 0.80
closeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected