Terminus
Public Types | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
terminus::NetworkEndpoint Class Reference

The NetworkEndpoint class provides a common interface that NetworkServer and NetworkClient implement. More...

#include <networkendpoint.h>

Inheritance diagram for terminus::NetworkEndpoint:
terminus::NetworkClient terminus::NetworkServer

Public Types

enum  State { State::Listening, State::Connected, State::Disconnected }
 

Signals

void receivedCommand (AbstractCommand *command)
 fired for every AbstractCommand received from the opposite NetworkEndpoint More...
 
void stateChanged (State newState)
 fired after state of this NetworkEndpoint is changed More...
 

Public Member Functions

 NetworkEndpoint (QObject *parent=0)
 
virtual ~NetworkEndpoint ()
 
void sendCommand (AbstractCommand *command)
 serializes command and sends it to the opposite NetworkEndpoint More...
 
void disconnect ()
 disconnect the underlying socket More...
 
State state ()
 

Protected Slots

void onDataReceived ()
 

Protected Member Functions

QTcpSocket * socket ()
 
void setSocket (QTcpSocket *socket)
 
void enterState (State state)
 
QString serializeCommand (AbstractCommand *command)
 
AbstractCommanddeserializeCommand (const QString &message)
 
void sendMessage (const QString &message)
 

Protected Attributes

State m_state
 
QTcpSocket * m_socket
 

Detailed Description

The NetworkEndpoint class provides a common interface that NetworkServer and NetworkClient implement.

It manages an underlying TcpSocket and implements logic to serialize and deserialize AbstractCommands

See also
NetworkServer, NetworkClient, AbstractCommand

Member Enumeration Documentation

Enumerator
Listening 
Connected 
Disconnected 

Constructor & Destructor Documentation

terminus::NetworkEndpoint::NetworkEndpoint ( QObject *  parent = 0)
terminus::NetworkEndpoint::~NetworkEndpoint ( )
virtual

Member Function Documentation

AbstractCommand * terminus::NetworkEndpoint::deserializeCommand ( const QString &  message)
protected
void terminus::NetworkEndpoint::disconnect ( )

disconnect the underlying socket

void terminus::NetworkEndpoint::enterState ( NetworkEndpoint::State  state)
protected
void terminus::NetworkEndpoint::onDataReceived ( )
protectedslot
void terminus::NetworkEndpoint::receivedCommand ( AbstractCommand command)
signal

fired for every AbstractCommand received from the opposite NetworkEndpoint

Parameters
command- ownership passes to receiver of this signal
void terminus::NetworkEndpoint::sendCommand ( AbstractCommand command)

serializes command and sends it to the opposite NetworkEndpoint

Parameters
command- ownership is not taken
void terminus::NetworkEndpoint::sendMessage ( const QString &  message)
protected
QString terminus::NetworkEndpoint::serializeCommand ( AbstractCommand command)
protected
void terminus::NetworkEndpoint::setSocket ( QTcpSocket *  socket)
protected
QTcpSocket * terminus::NetworkEndpoint::socket ( )
protected
NetworkEndpoint::State terminus::NetworkEndpoint::state ( )
Returns
current state of this NetworkEndpoint
void terminus::NetworkEndpoint::stateChanged ( State  newState)
signal

fired after state of this NetworkEndpoint is changed

Parameters
newState

Member Data Documentation

QTcpSocket* terminus::NetworkEndpoint::m_socket
protected
State terminus::NetworkEndpoint::m_state
protected

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