سؤال

Forgive me my bad English. I just started using qjsonrpc, and I like this thing. But recently I encountered a problem when using QJsonRpcTcpServer in my application: how can I keep track of a client connect/disconnect?

هل كانت مفيدة؟

المحلول

It seems you need to pass a QJsonRpcTcpServerPrivate instance to the QJsonRpcTcpServer::QJsonRpcTcpServer ctor, so I'd just subclass QJsonRpcTcpServerPrivate and override the following methods:

  • void QJsonRpcTcpServerPrivate::_q_processIncomingConnection()
  • void QJsonRpcTcpServerPrivate::_q_clientDisconnected()

github://devonit/qjsonrpc/src/qjsonrpctcpserver.cpp

You could then do something like casting the tcpSocket* to an appropriately long integer type and use that as the key to some dictionary/map.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top