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