-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved network version exchange protocol
This commit relaxes the check on the client side to allow connecting to servers with a more recent network protocol in the future. Clients also send their protocol version to the server. This information is simply ignored by older servers and does not break compatibility. The idea is to create a transition period after which the protocol can be modified (to exchange more information at connection time, such as support for stereo streams) without breaking compatibilty for clients and servers based on deflect >= 0.12.1.
- Loading branch information
Raphael Dumusc
committed
Feb 1, 2017
1 parent
2c41044
commit 52b7a2f
Showing
8 changed files
with
73 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*********************************************************************/ | ||
/* Copyright (c) 2013-2016, EPFL/Blue Brain Project */ | ||
/* Copyright (c) 2013-2017, EPFL/Blue Brain Project */ | ||
/* Raphael Dumusc <[email protected]> */ | ||
/* [email protected] */ | ||
/* All rights reserved. */ | ||
|
@@ -47,7 +47,10 @@ | |
|
||
#include <QDataStream> | ||
|
||
#define RECEIVE_TIMEOUT_MS 3000 | ||
namespace | ||
{ | ||
const int RECEIVE_TIMEOUT_MS = 3000; | ||
} | ||
|
||
namespace deflect | ||
{ | ||
|
@@ -56,6 +59,7 @@ ServerWorker::ServerWorker( const int socketDescriptor ) | |
// Ensure that tcpSocket_ parent is *this* so it gets moved to thread | ||
: _tcpSocket( new QTcpSocket( this )) | ||
, _sourceId( socketDescriptor ) | ||
, _clientProtocolVersion( NETWORK_PROTOCOL_VERSION ) | ||
, _registeredToEvents( false ) | ||
{ | ||
if( !_tcpSocket->setSocketDescriptor( socketDescriptor )) | ||
|
@@ -223,6 +227,9 @@ void ServerWorker::_handleMessage( const MessageHeader& messageHeader, | |
return; | ||
} | ||
_streamId = uri; | ||
// The version is only sent by deflect clients since v. 0.13.0 | ||
if( !byteArray.isEmpty( )) | ||
_parseClientProtocolVersion( byteArray ); | ||
emit addStreamSource( _streamId, _sourceId ); | ||
break; | ||
|
||
|
@@ -263,17 +270,22 @@ void ServerWorker::_handleMessage( const MessageHeader& messageHeader, | |
} | ||
} | ||
|
||
void ServerWorker::_handlePixelStreamMessage( const QByteArray& byteArray ) | ||
void ServerWorker::_parseClientProtocolVersion( const QByteArray& message ) | ||
{ | ||
const SegmentParameters* parameters = | ||
reinterpret_cast< const SegmentParameters* >( byteArray.data( )); | ||
bool ok = false; | ||
const int version = message.toInt( &ok ); | ||
if( ok ) | ||
_clientProtocolVersion = version; | ||
} | ||
|
||
void ServerWorker::_handlePixelStreamMessage( const QByteArray& message ) | ||
{ | ||
Segment segment; | ||
segment.parameters = *parameters; | ||
|
||
QByteArray imageData = | ||
byteArray.right( byteArray.size() - sizeof( SegmentParameters )); | ||
segment.imageData = imageData; | ||
const auto data = message.data(); | ||
segment.parameters = *reinterpret_cast<const SegmentParameters*>( data ); | ||
segment.imageData = message.right( message.size() - | ||
sizeof( SegmentParameters )); | ||
|
||
emit( receivedSegment( _streamId, _sourceId, segment )); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters