Commit 090c78ca authored by armin's avatar armin
Browse files

Merge branch 'iosWS' into 'master'

iremoved specil ios case as it now works

See merge request !124
parents 5948f653 cec2204b
...@@ -43,7 +43,7 @@ void MeteorDDP::init( const QString &pUri ) ...@@ -43,7 +43,7 @@ void MeteorDDP::init( const QString &pUri )
if ( unsecure ) { if ( unsecure ) {
protocol = QStringLiteral( "ws://" ); protocol = QStringLiteral( "ws://" );
} }
QUrl wsUri = QUrl( protocol + pUri + QStringLiteral( "/websocket" ) ); QUrl wsUri = QUrl( protocol + pUri + QStringLiteral( "/websocket" ) );
qDebug() << wsUri; qDebug() << wsUri;
qDebug() << "meteor init" ; qDebug() << "meteor init" ;
...@@ -53,10 +53,10 @@ void MeteorDDP::init( const QString &pUri ) ...@@ -53,10 +53,10 @@ void MeteorDDP::init( const QString &pUri )
connect( &mWebsocket, &QWebSocket::connected, this, &MeteorDDP::onConnected, Qt::UniqueConnection ); connect( &mWebsocket, &QWebSocket::connected, this, &MeteorDDP::onConnected, Qt::UniqueConnection );
connect( &mWebsocket, &QWebSocket::disconnected, this, &MeteorDDP::ddpDisconnected ); connect( &mWebsocket, &QWebSocket::disconnected, this, &MeteorDDP::ddpDisconnected );
connect( this, &MeteorDDP::sendMessageSignal, this, &MeteorDDP::sendJson, Qt::UniqueConnection ); connect( this, &MeteorDDP::sendMessageSignal, this, &MeteorDDP::sendJson, Qt::UniqueConnection );
connect( &mWebsocket, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error), connect( &mWebsocket, QOverload<QAbstractSocket::SocketError>::of( &QWebSocket::error ),
[=](QAbstractSocket::SocketError error){ [ = ]( QAbstractSocket::SocketError error ) {
qDebug()<<mWebsocket.errorString(); qDebug() << mWebsocket.errorString();
}); } );
mWebsocket.open( wsUri ); mWebsocket.open( wsUri );
QDateTime now = QDateTime::currentDateTime(); QDateTime now = QDateTime::currentDateTime();
...@@ -231,46 +231,32 @@ void MeteorDDP::sendRequest( const QSharedPointer<DDPRequest> &pDdpRequest ) ...@@ -231,46 +231,32 @@ void MeteorDDP::sendRequest( const QSharedPointer<DDPRequest> &pDdpRequest )
void MeteorDDP::resume() void MeteorDDP::resume()
{ {
qDebug() << "resuming ddp"; qDebug() << "resuming ddp";
qDebug() << "websocket valid: " << mWebsocket.isValid();
#if defined(Q_OS_ANDROID) || defined(Q_OS_LINUX) ||defined(Q_OS_WIN) || defined(Q_OS_OSX) QUrl wsUri = QUrl( QStringLiteral( "wss://" ) + mWebsocketUri + QStringLiteral( "/websocket" ) );
qDebug() << "websocket valid: " << mWebsocket.isValid();
QUrl wsUri = QUrl( QStringLiteral( "wss://" ) + mWebsocketUri + QStringLiteral( "/websocket" ) ); if ( mWebsocket.state() == QAbstractSocket::UnconnectedState ) {
mWebsocket.open( wsUri );
if ( mWebsocket.state() == QAbstractSocket::UnconnectedState ) { } else if ( mWebsocket.state() != QAbstractSocket::ConnectingState ) {
auto const connection = new QMetaObject::Connection;
*connection = connect( &mWebsocket, &QWebSocket::disconnected, [ = ]() {
qDebug() << "websocket closed";
mWebsocket.open( wsUri ); mWebsocket.open( wsUri );
} else if ( mWebsocket.state() != QAbstractSocket::ConnectingState ) { QDateTime now = QDateTime::currentDateTime();
auto const connection = new QMetaObject::Connection; uint currentTime = now.toTime_t();
*connection = connect( &mWebsocket, &QWebSocket::disconnected, [ = ]() { mLastPing = currentTime;
qDebug() << "websocket closed";
mWebsocket.open( wsUri );
QDateTime now = QDateTime::currentDateTime();
uint currentTime = now.toTime_t();
mLastPing = currentTime;
if ( connection != nullptr ) {
QObject::disconnect( *connection );
delete connection;
}
} );
mWebsocket.close();
}
if ( mWebsocket.state() == QAbstractSocket::UnconnectedState ) {
// connectWithServer();
}
#else if ( connection != nullptr ) {
qDebug() << "resuming ddp"; QObject::disconnect( *connection );
mWebsocket.close(); delete connection;
connect(&mWebsocket , &QWebSocket::disconnected, [&]() { }
qDebug()<<"disconnected";
init( mWebsocketUri );
} ); } );
mWebsocket.close(); mWebsocket.close();
}
#endif if ( mWebsocket.state() == QAbstractSocket::UnconnectedState ) {
// connectWithServer();
}
} }
void MeteorDDP::unsetResponseBinding( const QString &pId ) void MeteorDDP::unsetResponseBinding( const QString &pId )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment