本文整理汇总了C++中QWebSocket类的典型用法代码示例。如果您正苦于以下问题:C++ QWebSocket类的具体用法?C++ QWebSocket怎么用?C++ QWebSocket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWebSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processBinaryMessage
void wsServer::processBinaryMessage(QByteArray message)
{
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
if (pClient) {
pClient->sendBinaryMessage(message);
}
}
示例2: onDisconnected
void onDisconnected() {
JOYNR_LOG_TRACE(logger, "on disconnected");
QWebSocket* client = qobject_cast<QWebSocket*>(sender());
if(client) {
client->deleteLater();
}
}
示例3: socketDisconnected
// remove the client from when it disconneced
void ServerDeamon::socketDisconnected() {
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
if (pClient) {
m_clients.removeAll(pClient);
pClient->deleteLater();
}
}
示例4: connect
void ShtServer::onNewConnection()
{
QWebSocket *socket = socketServer->nextPendingConnection();
connect(socket, &QWebSocket::textMessageReceived, this, &ShtServer::onTextMessage);
connect(socket, &QWebSocket::disconnected, this, &ShtServer::onSocketDisconnected);
//onlineSockets << socket;
qWarning() << "Added socket " << socket->peerName() << ":" << socket->peerPort();
}
示例5: JsonApi
void WebSocketServer::onNewConnection()
{
QWebSocket *socket = m_pWebSocketServer->nextPendingConnection();
JsonApi *api = new JsonApi(socket, socket->peerAddress() == QHostAddress::LocalHost);
connect(socket, &QWebSocket::disconnected, this, &WebSocketServer::socketDisconnected);
connect(socket, &QWebSocket::textMessageReceived, api, &JsonApi::processMessage);
m_clients[socket] = api;
}
示例6: processTextMessage
//! [processTextMessage]
void SslEchoServer::processTextMessage(QString message)
{
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
if (pClient)
{
pClient->sendTextMessage(message);
}
}
示例7: socketDisconnected
void ReverseHashDServer::socketDisconnected() {
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
std::cout << "socketDisconnected:" << pClient << "\n";
if (pClient) {
m_clients.removeAll(pClient);
pClient->deleteLater();
}
}
示例8: socketDisconnected
void WsServer::socketDisconnected()
{
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
if (pClient) {
m_clients.removeAll(pClient);
emit newConnection(m_clients.count());
pClient->deleteLater();
}
}
示例9: processTextMessage
void EchoServer::processTextMessage(QString message)
{
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
//if (m_debug)
qDebug() << "Message received:" << message;
if (pClient) {
pClient->sendTextMessage(QString("服务器收到了") + message);
}
}
示例10: qDebug
//! [processTextMessage]
void BCWebSocketServer::processTextMessage(QString message)
{
qDebug() << message ;
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
if (pClient)
{
pClient->sendTextMessage(message);
}
}
示例11: processBinaryMessage
void Server::processBinaryMessage(QByteArray message)
{
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
if (m_debug)
qDebug() << "Binary Message received:" << message;
if (pClient) {
pClient->sendBinaryMessage(message);
}
}
示例12: qDebug
//! [socketDisconnected]
void SslEchoServer::socketDisconnected()
{
qDebug() << "Client disconnected";
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
if (pClient)
{
m_clients.removeAll(pClient);
pClient->deleteLater();
}
}
示例13: socketDisconnected
void Server::socketDisconnected()
{
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
if (m_debug)
qDebug() << "socketDisconnected:" << pClient;
if (pClient) {
m_clients.removeAll(pClient);
pClient->deleteLater();
}
}
示例14: foreach
// ---------------------------------------------------------------------
WsCln::~WsCln()
{
QWebSocket* socket;
foreach (socket, servers) {
#ifdef QT53
socket->close();
#else
socket->disconnectFromHost();
#endif
}
示例15: socketDisconnected
// _____________________________________________________________________
void CWebSocketServer::socketDisconnected()
{
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
if (pClient) {
int id = m_clients[pClient];
m_clients.remove(pClient);
m_clients_rev.remove(id);
pClient->deleteLater();
}
}