Torc  0.1
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Properties | List of all members
TorcNetworkService Class Reference

Encapsulates information on a discovered Torc peer. More...

#include <torcnetworkedcontext.h>

Inheritance diagram for TorcNetworkService:
[legend]

Public Types

enum  ServiceSource { Spontaneous = (0 << 0), Bonjour = (1 << 0), UPnP = (1 << 1) }
 

Public Slots

QString GetName (void)
 
QString GetUuid (void)
 
int GetPort (void)
 
QString GetHost (void)
 
QList< QHostAddress > GetAddresses (void)
 
QString GetAddress (void)
 
qint64 GetStartTime (void)
 
int GetPriority (void)
 
QString GetAPIVersion (void)
 
bool GetConnected (void)
 
void Connect (void)
 Establish a WebSocket connection to the peer if necessary. More...
 
void Connected (void)
 
void Disconnected (void)
 
void RequestReady (TorcNetworkRequest *Request)
 
void RequestReady (TorcRPCRequest *Request)
 

Signals

void StartTimeChanged (void)
 
void PriorityChanged (void)
 
void ApiVersionChanged (void)
 
void ConnectedChanged (void)
 
void TryConnect (void)
 

Public Member Functions

 TorcNetworkService (const QString &Name, const QString &UUID, int Port, bool Secure, const QList< QHostAddress > &Addresses)
 
 ~TorcNetworkService ()
 Destroy this service. More...
 
void SetHost (const QString &Host)
 
void SetStartTime (qint64 StartTime)
 
void SetPriority (int Priority)
 
void SetAPIVersion (const QString &Version)
 
void SetSource (ServiceSource Source)
 
ServiceSources GetSources (void)
 
void RemoveSource (ServiceSource Source)
 
void SetWebSocketThread (TorcWebSocketThread *Thread)
 
void RemoteRequest (TorcRPCRequest *Request)
 
void CancelRequest (TorcRPCRequest *Request)
 
QVariant ToMap (void)
 

Static Public Member Functions

static bool WeActAsServer (int Priority, qint64 StartTime, const QString &UUID)
 Determine whether we (the local device) should be the server for peer to peer communications. More...
 

Properties

QString name
 
QString uuid
 
int port
 
QString uiAddress
 
QString host
 
qint64 startTime
 
int priority
 
QString apiVersion
 
bool connected
 

Detailed Description

Encapsulates information on a discovered Torc peer.

Todo:
Should retries be limited? If support is added for manually specified peers (e.g. remote) and that peer is offline, need a better approach.

Definition at line 20 of file torcnetworkedcontext.h.

Member Enumeration Documentation

Enumerator
Spontaneous 
Bonjour 
UPnP 

Definition at line 26 of file torcnetworkedcontext.h.

Constructor & Destructor Documentation

TorcNetworkService::TorcNetworkService ( const QString &  Name,
const QString &  UUID,
int  Port,
bool  Secure,
const QList< QHostAddress > &  Addresses 
)

Definition at line 45 of file torcnetworkedcontext.cpp.

TorcNetworkService::~TorcNetworkService ( )

Destroy this service.

Note
When cancelling m_getPeerDetailsRPC, the call to TorcWebSocket::CancelRequest is blocking (to avoid leaking the request). Hence the request should always have been cancelled and downref'd when the call is complete. If the request happens to be processed while it is being cancelled, the request will no longer be valid for cancellation in the TorcWebSocket thread and if RequestReady is triggered in the TorcNetworkedContext thread (main thread), m_getPeerDetailsRPC will already have been released. This is because TorcWebSocket and TorcNetworkedContext process all of their updates in their own threads.
Todo:
Make the call to TorcNetwork::Cancel blocking, as for TorcWebSocket::CancelRequest.

Definition at line 96 of file torcnetworkedcontext.cpp.

Member Function Documentation

void TorcNetworkService::ApiVersionChanged ( void  )
signal
void TorcNetworkService::CancelRequest ( TorcRPCRequest Request)

Definition at line 506 of file torcnetworkedcontext.cpp.

void TorcNetworkService::Connect ( void  )
slot

Establish a WebSocket connection to the peer if necessary.

A connection is only established if we have the necessary details (address, API version, priority, start time etc) and this application should act as the client.

A client has a lower priority or later start time in the event of matching priorities.

Definition at line 150 of file torcnetworkedcontext.cpp.

void TorcNetworkService::Connected ( void  )
slot

Definition at line 243 of file torcnetworkedcontext.cpp.

void TorcNetworkService::ConnectedChanged ( void  )
signal
void TorcNetworkService::Disconnected ( void  )
slot

Definition at line 257 of file torcnetworkedcontext.cpp.

QString TorcNetworkService::GetAddress ( void  )
slot

Definition at line 218 of file torcnetworkedcontext.cpp.

QList< QHostAddress > TorcNetworkService::GetAddresses ( void  )
slot

Definition at line 531 of file torcnetworkedcontext.cpp.

QString TorcNetworkService::GetAPIVersion ( void  )
slot

Definition at line 233 of file torcnetworkedcontext.cpp.

bool TorcNetworkService::GetConnected ( void  )
slot

Definition at line 238 of file torcnetworkedcontext.cpp.

QString TorcNetworkService::GetHost ( void  )
slot

Definition at line 213 of file torcnetworkedcontext.cpp.

QString TorcNetworkService::GetName ( void  )
slot

Definition at line 198 of file torcnetworkedcontext.cpp.

int TorcNetworkService::GetPort ( void  )
slot

Definition at line 208 of file torcnetworkedcontext.cpp.

int TorcNetworkService::GetPriority ( void  )
slot

Definition at line 228 of file torcnetworkedcontext.cpp.

TorcNetworkService::ServiceSources TorcNetworkService::GetSources ( void  )

Definition at line 562 of file torcnetworkedcontext.cpp.

qint64 TorcNetworkService::GetStartTime ( void  )
slot

Definition at line 223 of file torcnetworkedcontext.cpp.

QString TorcNetworkService::GetUuid ( void  )
slot

Definition at line 203 of file torcnetworkedcontext.cpp.

void TorcNetworkService::PriorityChanged ( void  )
signal
void TorcNetworkService::RemoteRequest ( TorcRPCRequest Request)

Definition at line 490 of file torcnetworkedcontext.cpp.

void TorcNetworkService::RemoveSource ( ServiceSource  Source)

Definition at line 567 of file torcnetworkedcontext.cpp.

void TorcNetworkService::RequestReady ( TorcNetworkRequest Request)
slot

Definition at line 287 of file torcnetworkedcontext.cpp.

void TorcNetworkService::RequestReady ( TorcRPCRequest Request)
slot

Definition at line 341 of file torcnetworkedcontext.cpp.

void TorcNetworkService::SetAPIVersion ( const QString &  Version)

Definition at line 552 of file torcnetworkedcontext.cpp.

void TorcNetworkService::SetHost ( const QString &  Host)

Definition at line 536 of file torcnetworkedcontext.cpp.

void TorcNetworkService::SetPriority ( int  Priority)

Definition at line 547 of file torcnetworkedcontext.cpp.

void TorcNetworkService::SetSource ( ServiceSource  Source)

Definition at line 557 of file torcnetworkedcontext.cpp.

void TorcNetworkService::SetStartTime ( qint64  StartTime)

Definition at line 542 of file torcnetworkedcontext.cpp.

void TorcNetworkService::SetWebSocketThread ( TorcWebSocketThread Thread)

Definition at line 472 of file torcnetworkedcontext.cpp.

void TorcNetworkService::StartTimeChanged ( void  )
signal
QVariant TorcNetworkService::ToMap ( void  )

Definition at line 517 of file torcnetworkedcontext.cpp.

void TorcNetworkService::TryConnect ( void  )
signal
bool TorcNetworkService::WeActAsServer ( int  Priority,
qint64  StartTime,
const QString &  UUID 
)
static

Determine whether we (the local device) should be the server for peer to peer communications.

The server is the instance with:

  • higher priority
  • same priority but earlier start time
  • same priority and start time but 'bigger' UUID

Definition at line 132 of file torcnetworkedcontext.cpp.

Property Documentation

QString TorcNetworkService::apiVersion
read

Definition at line 47 of file torcnetworkedcontext.h.

bool TorcNetworkService::connected
read

Definition at line 48 of file torcnetworkedcontext.h.

QString TorcNetworkService::host
read

Definition at line 44 of file torcnetworkedcontext.h.

QString TorcNetworkService::name
read

Definition at line 40 of file torcnetworkedcontext.h.

int TorcNetworkService::port
read

Definition at line 42 of file torcnetworkedcontext.h.

int TorcNetworkService::priority
read

Definition at line 46 of file torcnetworkedcontext.h.

qint64 TorcNetworkService::startTime
read

Definition at line 45 of file torcnetworkedcontext.h.

QString TorcNetworkService::uiAddress
read

Definition at line 43 of file torcnetworkedcontext.h.

QString TorcNetworkService::uuid
read

Definition at line 41 of file torcnetworkedcontext.h.


The documentation for this class was generated from the following files: