sP2P c++ STL *nix API  1.2
NAT traversal and peer-to-peer networking API providing all utilities needed to build peer-to-peer application straigth out of box
 All Classes Functions Variables Typedefs Enumerations Enumerator
sp2plib::ConnectionManager Class Reference

Manages communication with checkpoint service hosted with supernode. ConnectionManager is main object you use with API. All client operations are initiated using methods in this class with exception of virtual index manager which is sub object of ConnectionManager (ConnnectionManager.VNIndexManager()). More...

#include <ConnectionManager.h>

Inheritance diagram for sp2plib::ConnectionManager:
sp2plib::sP2PBase

Public Types

enum  ConnectionManagerStatus { CMS_NONE = 0, CMS_CONNECTING = 1, CMS_CONNECTED = 2, CMS_DOWN = 3 }
 Status of PeerManager More...
 
enum  SessionFailReason {
  SFR_NONE = 0, SFR_TIMEOUT_EXPIRED = 1, SFR_AUTHENTFICATION_FAILURE = 2, SFR_SERVER_UNREACHABLE = 3,
  SFR_CLIENT_ERROR = 4, SFR_API_VERSION_UNSUPPORTED = 5
}
 Reason for not opening session with checkpoint server More...
 
enum  PeerConnectFailureReason {
  PCFR_NONE = 0, PCFR_UNKNOWN = 1, PCFR_PEER_NOT_FOUND = 2, PCFR_TIMEOUT_EXPIRED = 3,
  PCFR_REFUSED_BY_PEER = 4, PCFR_HANDSHAKE_UNSUCCESSFUL = 5, PCFR_OPERATION_FORBIDEN_ON_NETWORK = 6
}
 Reason for not initiating connection to peer More...
 
typedef Delegate
< ConnectionManager *, Peer
*, ConnectionType, bool * > * 
AcceptPeerConnection
 Function pointer for function deciding of peer acceptance. By default only .BlockIncoming parameter is considered
 
typedef Delegate
< ConnectionManager
*, ConnectionManagerStatus > * 
StatusChange
 Status change delegate
 
typedef Delegate
< ConnectionManager * > * 
SessionOpenSuccess
 Session open with success function pointer
 
typedef Delegate
< ConnectionManager
*, SessionFailReason > * 
SessionOpenFailure
 Session open failure function pointer
 
typedef Delegate
< ConnectionManager *, bool,
SessionFailReason > * 
SessionOpenCallback
 Session open callback function pointer
 
typedef Delegate
< ConnectionManager * > * 
SessionDrop
 Session drop callback function pointer
 
typedef Delegate< Peer *, Guid * > * PeerConnect
 Function pointer for function to trigger when connection to peer (if connect) is successfully created
 
typedef Delegate< Peer *, Guid * > * PeerAccept
 Function pointer for function to trigger when connection to peer (if accept) is successfully created
 
typedef Delegate< Peer *, int,
bool, Guid *, int, int, int > * 
PeerQueryCompleted
 Function pointer to function to be called on results arrival after peer query request
 
typedef Delegate< Peer
*, sp2plib::UInt32 > * 
PeerStateChanged
 Function pointer to function to be called to be called when information about peer state change arrives
 
typedef Delegate< Peer *, Guid
*, Guid *, Guid *, bool,
PeerConnectFailureReason > * 
PeerConnectCallback
 Function pointer to pass as argument to ConnectionManager.Connect to be executed on connecton creation
 
typedef Delegate< Guid *, Guid
*, Guid *, int, unsigned char
*, int > * 
ReceiveInstantMessage
 Function pointer to function to be called when instant message is Received
 
typedef Delegate< Guid *, Guid
*, Guid
*, PeerConnectFailureReason > * 
PeerConnectFailure
 Function pointer for function to be called when connection attempt fails
 
typedef Delegate< Guid *, bool > * SendInstantMessageComplete
 Function pointer for function to be called when instant message is sent to checkpoint server
 
typedef Delegate< Guid * > * StateTrackActionFailed
 Function pointer for function to be called when state track action (register/un-register tracking) fails
 
typedef Delegate
< ConnectionManager
*, IP4Address * > * 
NetworkInterfaceChange
 Function pointer for function to be called when ConnectionManager dispatcher network interface changes
 

Public Member Functions

 ConnectionManager (IPEndPoint SupernodeEP, IPEndPoint LocalBindPoint)
 Initializes new instance of ConnectionManager class
 
 ConnectionManager (IPEndPoint SupernodeEP)
 Initializes new instance of ConnectionManager class
 
virtual ::std::string ObjectClassName ()
 
void SetAcceptPeerConnectionResolver (AcceptPeerConnection Delegate)
 Sets function pointer of type sp2plib::ConnectionManager::AcceptPeerConnection to function that desides will remote peer be alowed to connect or not . By default only sp2plib::ConnectionManager.BlockIncoming parameter is considered
 
void Open (SessionOpenCallback Callback=NULL)
 Opens session with checkpoint server
 
void Close ()
 Closes session with checkpoint server
 
Guid Query (Guid PeerUID, PeerQueryCompleted Callback=NULL)
 Queries remote peer by its UID
 
Guid Query (::std::string QueryText, PeerQueryCompleted Callback=NULL, int page=0, int pageLimit=64)
 Queries remote peers by their application specific parameters
 
Guid RegisterStateTracking (Guid &PeerUID)
 Register for receiving informations about peer state changes
 
Guid UnregisterStateTracking (Guid &PeerUID)
 Unregister for receiving informations about peer state changes
 
Guid RegisterStateTracking (::std::list< Guid > *PeerUIDList)
 Register for receiving informations about peers state changes
 
Guid UnregisterStateTracking (::std::list< Guid > *PeerUIDList)
 Unregister for receiving informations about peers state changes
 
Guid SendInstantMessage (Guid RemotePeerCheckpointUID, Guid RemotePeerUID, unsigned char *message_buffer, int message_len, int InstantMessageType=0, SendInstantMessageComplete Callback=NULL)
 Sends instant message to remote peer using checkpoint server system
 
Guid SendInstantMessage (Guid RemotePeerCheckpointUID, Guid RemotePeerUID,::std::string Message, int InstantMessageType=0, SendInstantMessageComplete Callback=NULL)
 Sends instant message to remote peer using checkpoint server system
 
Guid SendInstantMessage (Peer &Peer, unsigned char *message_buffer, int message_len, int InstantMessageType=0, SendInstantMessageComplete Callback=NULL)
 Sends instant message to remote peer using checkpoint server system
 
Guid SendInstantMessage (Peer &Peer,::std::string Message, int InstantMessageType=0, SendInstantMessageComplete Callback=NULL)
 Sends instant message to remote peer using checkpoint server system
 
Guid BrodcastStateChange ()
 Sends information of local peer state change to checkpoint and all other peers registered to track local peer state
 
Guid Connect (Peer &Peer, ConnectionType ConnectionType, IPEndPoint BindEndPoint=IPEndPoint::ANY(), PeerConnectCallback callback=NULL)
 Connects to peer using information given in a peer object
 
Guid Connect (Peer &Peer, ConnectionType ConnectionType, Guid UserTransactionUID, IPEndPoint BindEndPoint=IPEndPoint::ANY(), PeerConnectCallback callback=NULL)
 Connects to peer using information given in a peer object
 
Guid Connect (Guid CheckPointUID, Guid PeerUID, ConnectionType ConnectionType, IPEndPoint BindEndPoint=IPEndPoint::ANY(), PeerConnectCallback callback=NULL)
 Connect to peer using identifiers of peer itself and it's checkpoint
 
Guid Connect (Guid CheckPointUID, Guid PeerUID, ConnectionType ConnectionType, Guid UserTransactionUID, IPEndPoint BindEndPoint=IPEndPoint::ANY(), PeerConnectCallback callback=NULL)
 Connect to peer using identifiers of peer itself and it's checkpoint
 
ConnectionManagerStatus GetStatus ()
 Gets status (sp2plib::ConnectionManager::ConnectionManagerStatus) of ConnectionManager
 
void join_primary_thread ()
 Stops current thread execution as long as ConnectionManager object is not disposed (deleted)
 
void Delay (Delegate<> *FunctionDelegate, int milisec)
 Executes delegate function with delay
 
void Dispose ()
 Use this method when you want to delete ConnectionManager object, you don't need to call delete *ConnectionManager; after
 
VNManagerVNIndexManager ()
 Gets virtual index storage manager object used for virtual users/networks object manipulation
 
void setAccessTokens (Guid providerUID, Guid applicationUID,::std::string accessKey)
 Sets access parameters to needed to get into sP2P stsyem
 
bool ___crssthread_is_disposed ()
 
- Public Member Functions inherited from sp2plib::sP2PBase
virtual ::std::string ObjectClassName ()
 
void WriteLogEntry (::std::string Text)
 

Static Public Member Functions

::std::string ConnectionManagerStatusName (ConnectionManagerStatus Status)
 Converts ConnectionManagerStatus variable to value name string
 
::std::string SessionFailReasonName (SessionFailReason Reason)
 Converts SessionFailReason variable to value name string
 
::std::string PeerConnectFailureReasonName (PeerConnectFailureReason Reason)
 Converts PeerConnectFailureReason variable to value name string
 

Public Attributes

Event< ConnectionManager
*, ConnectionManagerStatus
onStatusChange
 Raised each time servers status changes
 
Event< ConnectionManager * > onSessionOpenSuccess
 Raised when session with Check Point server session becomes active
 
Event< ConnectionManager
*, SessionFailReason
onSessionOpenFailure
 Raised when session with Check Point server session fails to open
 
Event< ConnectionManager * > onSessionDrop
 Raised on session drop
 
Event< Peer *, Guid * > onPeerConnected
 Raised when connection requested by local peer to remote peer is successfully created
 
Event< Peer *, int, bool, Guid
*, int, int, int > 
onPeerQueryResponse
 Raised when peer query response arrives
 
Event< Peer *, sp2plib::UInt32 > onPeerStateChanged
 Raised when information about peer state change arrives (RegisterStateTracking function must be peformed to be able to receve this information)
 
Event< Guid *, Guid *, Guid
*, int, unsigned char *, int > 
onReceiveInstantMessage
 Raised when instant message arrives. (DO NOT USE unsigned char* POINTER VARIABLE OUSIDE HANDLER FUNCTION SCOPE, BECUSE HEAP WILL BE DE-ALLOCATED (delete[]) WHEN SCOPE IS EXITED, THIS ALSO MEANS THAT YOU DONT HAVE TO CALL delete[] Data; YOURSELF! IF YOU NEED THIS RAW BYTE DATA FOR LATER USE COPY IT TO OTHER BUFFER)
 
Event< Peer *, Guid * > onPeerAccepted
 Raised when connection requested by remote peer to local peer is successfully created
 
Event< Guid *, Guid *, Guid
*, PeerConnectFailureReason
onPeerAcceptFailure
 Raised when tunnel creation requested from remote peer fails
 
Event< Guid *, Guid *, Guid
*, PeerConnectFailureReason
onPeerConnectFailure
 Raised when tunnel creation requested to remote peer fails
 
Event< Guid *, bool > onSendInstantMessageComplete
 Raised when instant message is sent to checkpoint server
 
Event< Guid * > onStateTrackActionFailed
 Raised when state track action (register/un-register tracking) fails
 
Event< ConnectionManager
*, IP4Address * > 
onNetworkInterfaceChange
 Raised when ConnectionManager dispatcher network interface changes
 
PeerConnectCallback PeerAccepted
 Get of sets function pointer of type sp2plib::ConnectionManager::PeerConnect to call on peer acceptance as callback function
 
::std::queue< int > AcceptPortQueue
 If some specific local ports for socket that will be used for accepting connection to remote peer is desired, this queue can be filled with user definded values which will be dequed in that same order
 
Peer LocalPeer
 Local client peer object
 
int CheckPointTimeout
 Gets or sets max. time in milliseconds to wait response form checkpoint server. Default value is 12000 (12 seconds).
 
bool BlockIncoming
 If set to true other peers will not be able to connect
 
bool MaintainSession
 Gets or sets a value indicating that session establishment with checkpoint should be retried in case of session drop or initial session open failure due TIMEOUT until ConnectionManager.close() method is called. [Default: True]
 
class SP2P_API HandshakeClient
 

Detailed Description

Manages communication with checkpoint service hosted with supernode. ConnectionManager is main object you use with API. All client operations are initiated using methods in this class with exception of virtual index manager which is sub object of ConnectionManager (ConnnectionManager.VNIndexManager()).

Member Typedef Documentation

Function pointer for function deciding of peer acceptance. By default only .BlockIncoming parameter is considered

Parameters
ConnectionManagerConnection manager
PeerPeer requesting connection
ConnectionTypeRequested connection protocol type
AllowOutput parameter as result of operation: true - alow connection , false - disallow connection

Function pointer for function to be called when ConnectionManager dispatcher network interface changes

Parameters
ConnectionManagerConnectionManager that raised event
IP4AddressNew address dispatcher is bound to

Function pointer for function to trigger when connection to peer (if accept) is successfully created

Parameters
PeerAccepted peer
TransactionUIDUnique identifier on connect operation

Function pointer for function to trigger when connection to peer (if connect) is successfully created

Parameters
PeerConnected peer
TransactionUIDUnique identifier on connect operation

Function pointer to pass as argument to ConnectionManager.Connect to be executed on connecton creation

Parameters
PeerPeer object (remote peer) if success = true , otherwise null
PeerCheckpointUIDUnique identifier of remote peer's checkpoint
PeerUIDUnique identifier of remote peer
TransactionUIDUnique operation of connect operation
SuccessOutcome of connect operation
FailReasonIf success = false , then reason for failing

Function pointer for function to be called when connection attempt fails

Parameters
PeerCheckpointUIDCheckpoint UID of peer to whom connection creation was attempted
PeerUIDUID of peer to whom connection creation was attempted
TransactionUIDTransaction UID
ReasonReason of failure
typedef Delegate<Peer*,int, bool, Guid*, int, int, int>* sp2plib::ConnectionManager::PeerQueryCompleted

Function pointer to function to be called on results arrival after peer query request

Parameters
FoundPeersList of peers returned by query
CountNumber of peers returned by query
CompletedIf completed then true, not that sometimes result will contain peers but this value will be false. This can happen for example if 10000000 peers are found by serch creterium , and operation timeout expires before all results are collected
QueryTransactionIDTransaction ID of query request
PagePage returned if pagination exists
PageLimitNumber of peers per page if pagination exists
TotalPeersTotal number of peers matched by query

Function pointer to function to be called to be called when information about peer state change arrives

Parameters
PeerPeer that changed state
StateValue of the peer's state field
typedef Delegate<Guid*, Guid*, Guid*, int, unsigned char *,int>* sp2plib::ConnectionManager::ReceiveInstantMessage

Function pointer to function to be called when instant message is Received

Parameters
FromPeerUID (Unique identifier) of remote peer that has sent instant message
FromPeerCheckpointUID (Unique identifier) of remote peer' checkpoint server that has sent instant message
MessageGUIDUnique identifier of message
MessageTypeInteger value that can be used to distinguish instant messages by several different types if needed in application
DataReceived bytes (DO NOT USE POINTER VARIABLE OUSIDE HANDLER FUNCTION SCOPE, BECUSE HEAP WILL BE DE-ALLOCATED (delete[]) WHEN SCOPE IS EXITED, THIS ALSO MEANS THAT YOU DONT HAVE TO CALL delete[] Data; YOURSELF! IF YOU NEED THIS RAW BYTE DATA FOR LATER USE COPY IT TO OTHER BUFFER)
DataSizeSize of Data array

Function pointer for function to be called when instant message is sent to checkpoint server

Parameters
MessageGUIDUID of instant message
successtrue if sending was successful, otherwise false

Session drop callback function pointer

Parameters
ConnectionManagerConnection manager witch session droped

Session open callback function pointer

Parameters
ConnectionManagerCallback to use wiht ConnetionManager.Open function to be execute on operation completion
SuccessOutcome of session opening proccess
ReasonIf Success false , gives reason for that outcome

Session open failure function pointer

Parameters
ConnectionManagerConnectionManager that tried opening session
ReasonReason

Session open with success function pointer

Parameters
ConnectionManagerConnectionManager that opened session

Function pointer for function to be called when state track action (register/un-register tracking) fails

Parameters
TransactionUIDUID of transaction

Status change delegate

Parameters
senderSending service
StatusCurrent status

Member Enumeration Documentation

Status of PeerManager

Enumerator:
CMS_NONE 

ConnectionManeger is initialized but there is no session

CMS_CONNECTING 

ConnectionManeger is in session opening process

CMS_CONNECTED 

Session is active, ConnectionManeger is connected to Checkpoint server

CMS_DOWN 

Session is forcedly closed by unattended factor

Reason for not initiating connection to peer

Enumerator:
PCFR_NONE 

None because it finished successfully

PCFR_UNKNOWN 

The reason is unknown

PCFR_PEER_NOT_FOUND 

Remote peer could not be located

PCFR_TIMEOUT_EXPIRED 

Time period reserved for operation execution has expired

PCFR_REFUSED_BY_PEER 

Remote peer has actively refused connection

PCFR_HANDSHAKE_UNSUCCESSFUL 

Handshake operation failed

PCFR_OPERATION_FORBIDEN_ON_NETWORK 

Supernode stoped operation - ususaly if application use licence expires

Reason for not opening session with checkpoint server

Enumerator:
SFR_NONE 

If session opening is finished with success

SFR_TIMEOUT_EXPIRED 

Response from CheckPoint server has not arrived in timeout period

SFR_AUTHENTFICATION_FAILURE 

Can not authenticate with CheckPoint server

SFR_SERVER_UNREACHABLE 

CheckPoint server is unreachable

SFR_CLIENT_ERROR 

Error on client side

SFR_API_VERSION_UNSUPPORTED 

Server does not support API version used by client

Constructor & Destructor Documentation

sp2plib::ConnectionManager::ConnectionManager ( IPEndPoint  SupernodeEP,
IPEndPoint  LocalBindPoint 
)

Initializes new instance of ConnectionManager class

Parameters
SupernodeEPIP End Point of supernode ConnectionManager will connect to
LocalBindPointLocal end point to bind internal connection manager socket to (not recomended if you are not sure what you are doing!)
sp2plib::ConnectionManager::ConnectionManager ( IPEndPoint  SupernodeEP)

Initializes new instance of ConnectionManager class

Parameters
SupernodeEPIP End Point of supernode ConnectionManager will connect to

Member Function Documentation

Guid sp2plib::ConnectionManager::BrodcastStateChange ( )

Sends information of local peer state change to checkpoint and all other peers registered to track local peer state

Returns
UID of transaction, Guid::Empty() if not executed
void sp2plib::ConnectionManager::Close ( )

Closes session with checkpoint server

Guid sp2plib::ConnectionManager::Connect ( Peer Peer,
ConnectionType  ConnectionType,
IPEndPoint  BindEndPoint = IPEndPoint::ANY(),
PeerConnectCallback  callback = NULL 
)

Connects to peer using information given in a peer object

Parameters
PeerPeer object containing information of peer to whom we connect
ConnectionTypeProtocol (TCP/UDP) to be used for connection
BindEndPointLocal end-point to bind result socket to
callbackFunction delegate of type PeerConnectDelagate to execute on connection completion
Returns
TransactionUID of connect operation
Guid sp2plib::ConnectionManager::Connect ( Peer Peer,
ConnectionType  ConnectionType,
Guid  UserTransactionUID,
IPEndPoint  BindEndPoint = IPEndPoint::ANY(),
PeerConnectCallback  callback = NULL 
)

Connects to peer using information given in a peer object

Parameters
PeerPeer object containing information of peer to whom we connect
ConnectionTypeProtocol (TCP/UDP) to be used for connection
UserTransactionUIDUser defined transaction UID - useful when peers have need to open multiple tunnels. They can negotiate UID before connect operation, and connection accepter can distungish tunnel connection
BindEndPointLocal end-point to bind result socket to
callbackFunction delegate of type PeerConnectDelagate to execute on connection completion
Returns
TransactionUID of connect operation
Guid sp2plib::ConnectionManager::Connect ( Guid  CheckPointUID,
Guid  PeerUID,
ConnectionType  ConnectionType,
IPEndPoint  BindEndPoint = IPEndPoint::ANY(),
PeerConnectCallback  callback = NULL 
)

Connect to peer using identifiers of peer itself and it's checkpoint

Parameters
CheckPointUIDPeer's CheckPoint Unique Identifier
PeerUIDPeer's Unique Identifier
ConnectionTypeProtocol (TCP/UDP) to be used for connection
BindEndPointLocal end-point to bind result socket to
callbackFunction delegate of type PeerConnectDelagate to execute on connection completion
Returns
TransactionUID of connect operation
Guid sp2plib::ConnectionManager::Connect ( Guid  CheckPointUID,
Guid  PeerUID,
ConnectionType  ConnectionType,
Guid  UserTransactionUID,
IPEndPoint  BindEndPoint = IPEndPoint::ANY(),
PeerConnectCallback  callback = NULL 
)

Connect to peer using identifiers of peer itself and it's checkpoint

Parameters
CheckPointUIDPeer's CheckPoint Unique Identifier
PeerUIDPeer's Unique Identifier
ConnectionTypeProtocol (TCP/UDP) to be used for connection
UserTransactionUIDUser defined transaction UID - useful when peers have need to open multiple tunnels. They can negotiate UID before connect operation, and connection accepter can distungish tunnel connection
BindEndPointLocal end-point to bind result socket to
callbackFunction delegate of type PeerConnectDelagate to execute on connection completion
Returns
TransactionUID of connect operation
::std::string sp2plib::ConnectionManager::ConnectionManagerStatusName ( ConnectionManagerStatus  Status)
static

Converts ConnectionManagerStatus variable to value name string

void sp2plib::ConnectionManager::Delay ( Delegate<> *  FunctionDelegate,
int  milisec 
)

Executes delegate function with delay

Parameters
FunctionDelegateNo argument sp2plib delegate for function to be executed
milisecNumber of milliseconds to delay execution
void sp2plib::ConnectionManager::Dispose ( )

Use this method when you want to delete ConnectionManager object, you don't need to call delete *ConnectionManager; after

ConnectionManagerStatus sp2plib::ConnectionManager::GetStatus ( )
void sp2plib::ConnectionManager::join_primary_thread ( )

Stops current thread execution as long as ConnectionManager object is not disposed (deleted)

void sp2plib::ConnectionManager::Open ( SessionOpenCallback  Callback = NULL)

Opens session with checkpoint server

Parameters
CallbackCallback to execute on session open procedure completion
::std::string sp2plib::ConnectionManager::PeerConnectFailureReasonName ( PeerConnectFailureReason  Reason)
static

Converts PeerConnectFailureReason variable to value name string

Guid sp2plib::ConnectionManager::Query ( Guid  PeerUID,
PeerQueryCompleted  Callback = NULL 
)

Queries remote peer by its UID

Parameters
PeerUIDUID of remote peer
CallbackCallback to execute on result arrival
Returns
Transaction ID of query request message. If something wrong Guid.empty will be returned
Guid sp2plib::ConnectionManager::Query ( ::std::string  QueryText,
PeerQueryCompleted  Callback = NULL,
int  page = 0,
int  pageLimit = 64 
)

Queries remote peers by their application specific parameters

Parameters
QueryTextNoSQL query command text
CallbackCallback to execute on result arrival
pagePagination page
pageLimitMaximal number of peers to return per pagination page(request), default is 64, miximum 256
Returns
Transaction ID of query request message. If something wrong Guid::empty() will be returned
Guid sp2plib::ConnectionManager::RegisterStateTracking ( Guid PeerUID)

Register for receiving informations about peer state changes

Parameters
PeerUID of peer to track
Returns
UID of transaction, Guid::Empty() if not executed
Guid sp2plib::ConnectionManager::RegisterStateTracking ( ::std::list< Guid > *  PeerUIDList)

Register for receiving informations about peers state changes

Parameters
PeerUIDListList of peers UIDs to track
Returns
UID of transaction, Guid::Empty() if not executed
Guid sp2plib::ConnectionManager::SendInstantMessage ( Guid  RemotePeerCheckpointUID,
Guid  RemotePeerUID,
unsigned char *  message_buffer,
int  message_len,
int  InstantMessageType = 0,
SendInstantMessageComplete  Callback = NULL 
)

Sends instant message to remote peer using checkpoint server system

Parameters
RemotePeerCheckpointUIDCheckpoint UID of remote peer
RemotePeerUIDUID of remote peer
message_bufferBuffer containing message
message_lenSize of message byte array serialization, MAX : 85196800
InstantMessageTypeField that can be used freely in application to distinguish instant messages types, like chat text, control message ...
CallbackCallback to execute upon message sending completion, note that this is completion of sending message to checkpoint not other peer
Returns
Randomly generated Guid for message, it can be used in later procesing to distinguish particular message
Guid sp2plib::ConnectionManager::SendInstantMessage ( Guid  RemotePeerCheckpointUID,
Guid  RemotePeerUID,
::std::string  Message,
int  InstantMessageType = 0,
SendInstantMessageComplete  Callback = NULL 
)

Sends instant message to remote peer using checkpoint server system

Parameters
RemotePeerCheckpointUIDCheckpoint UID of remote peer
RemotePeerUIDUID of remote peer
MessageMessage text
InstantMessageTypeField that can be used freely in application to distinguish instant messages types, like chat text, control message ...
CallbackCallback to execute upon message sending completion, note that this is completion of sending message to checkpoint not other peer
Returns
Randomly generated Guid for message, it can be used in later processing to distinguish particular message
Guid sp2plib::ConnectionManager::SendInstantMessage ( Peer Peer,
unsigned char *  message_buffer,
int  message_len,
int  InstantMessageType = 0,
SendInstantMessageComplete  Callback = NULL 
)

Sends instant message to remote peer using checkpoint server system

Parameters
PeerRemote peer to send message to
message_bufferBuffer containing message
message_lenSize of message byte array serialization, MAX : 85196800
InstantMessageTypeField that can be used freely in application to distinguish instant messages types, like chat text, control message ...
CallbackCallback to execute upon message sending completion, note that this is completion of sending message to checkpoint not other peer
Returns
Randomly generated Guid for message, it can be used in later processing to distinguish particular message
Guid sp2plib::ConnectionManager::SendInstantMessage ( Peer Peer,
::std::string  Message,
int  InstantMessageType = 0,
SendInstantMessageComplete  Callback = NULL 
)

Sends instant message to remote peer using checkpoint server system

Parameters
PeerRemote peer to send message to
MessageMessage text
InstantMessageTypeField that can be used freely in application to distinguish instant messages types, like chat text, control message ...
CallbackCallback to execute upon message sending completion, note that this is completion of sending message to checkpoint not other peer
Returns
Randomly generated Guid for message, it can be used in later processing to distinguish particular message
::std::string sp2plib::ConnectionManager::SessionFailReasonName ( SessionFailReason  Reason)
static

Converts SessionFailReason variable to value name string

void sp2plib::ConnectionManager::SetAcceptPeerConnectionResolver ( AcceptPeerConnection  Delegate)

Sets function pointer of type sp2plib::ConnectionManager::AcceptPeerConnection to function that desides will remote peer be alowed to connect or not . By default only sp2plib::ConnectionManager.BlockIncoming parameter is considered

void sp2plib::ConnectionManager::setAccessTokens ( Guid  providerUID,
Guid  applicationUID,
::std::string  accessKey 
)

Sets access parameters to needed to get into sP2P stsyem

Parameters
ProviderUIDProvider Token To Identify Application Provider
ApplicationUIDApplication Token To Identify Application
AccessKeyAccess Key
Guid sp2plib::ConnectionManager::UnregisterStateTracking ( Guid PeerUID)

Unregister for receiving informations about peer state changes

Parameters
PeerUID of peer to stop tracking
Returns
UID of transaction, Guid::Empty() if not executed
Guid sp2plib::ConnectionManager::UnregisterStateTracking ( ::std::list< Guid > *  PeerUIDList)

Unregister for receiving informations about peers state changes

Parameters
PeerUIDListList of peers UIDs to stop tracking
Returns
UID of transaction, Guid::Empty() if not executed
VNManager* sp2plib::ConnectionManager::VNIndexManager ( )

Gets virtual index storage manager object used for virtual users/networks object manipulation

It's recommended that you always use ConnectionManager.IndexManager property to access this object, because for example in case of silent redirect this object may change

Member Data Documentation

::std::queue<int> sp2plib::ConnectionManager::AcceptPortQueue

If some specific local ports for socket that will be used for accepting connection to remote peer is desired, this queue can be filled with user definded values which will be dequed in that same order

bool sp2plib::ConnectionManager::BlockIncoming

If set to true other peers will not be able to connect

int sp2plib::ConnectionManager::CheckPointTimeout

Gets or sets max. time in milliseconds to wait response form checkpoint server. Default value is 12000 (12 seconds).

Peer sp2plib::ConnectionManager::LocalPeer

Local client peer object

bool sp2plib::ConnectionManager::MaintainSession

Gets or sets a value indicating that session establishment with checkpoint should be retried in case of session drop or initial session open failure due TIMEOUT until ConnectionManager.close() method is called. [Default: True]

true if session should be maintained, false if not.

Event<ConnectionManager*, IP4Address*> sp2plib::ConnectionManager::onNetworkInterfaceChange

Raised when ConnectionManager dispatcher network interface changes

Event<Peer*, Guid*> sp2plib::ConnectionManager::onPeerAccepted

Raised when connection requested by remote peer to local peer is successfully created

Event<Guid*, Guid*, Guid*, PeerConnectFailureReason> sp2plib::ConnectionManager::onPeerAcceptFailure

Raised when tunnel creation requested from remote peer fails

Event<Peer*, Guid*> sp2plib::ConnectionManager::onPeerConnected

Raised when connection requested by local peer to remote peer is successfully created

Event<Guid*, Guid*, Guid*, PeerConnectFailureReason> sp2plib::ConnectionManager::onPeerConnectFailure

Raised when tunnel creation requested to remote peer fails

Event<Peer*,int, bool, Guid*, int, int, int> sp2plib::ConnectionManager::onPeerQueryResponse

Raised when peer query response arrives

Event<Peer*, sp2plib::UInt32> sp2plib::ConnectionManager::onPeerStateChanged

Raised when information about peer state change arrives (RegisterStateTracking function must be peformed to be able to receve this information)

Event<Guid*, Guid*, Guid*, int, unsigned char*,int> sp2plib::ConnectionManager::onReceiveInstantMessage

Raised when instant message arrives. (DO NOT USE unsigned char* POINTER VARIABLE OUSIDE HANDLER FUNCTION SCOPE, BECUSE HEAP WILL BE DE-ALLOCATED (delete[]) WHEN SCOPE IS EXITED, THIS ALSO MEANS THAT YOU DONT HAVE TO CALL delete[] Data; YOURSELF! IF YOU NEED THIS RAW BYTE DATA FOR LATER USE COPY IT TO OTHER BUFFER)

Event<Guid*, bool> sp2plib::ConnectionManager::onSendInstantMessageComplete

Raised when instant message is sent to checkpoint server

Event<ConnectionManager *> sp2plib::ConnectionManager::onSessionDrop

Raised on session drop

Event<ConnectionManager *, SessionFailReason> sp2plib::ConnectionManager::onSessionOpenFailure

Raised when session with Check Point server session fails to open

Event<ConnectionManager *> sp2plib::ConnectionManager::onSessionOpenSuccess

Raised when session with Check Point server session becomes active

Event<Guid*> sp2plib::ConnectionManager::onStateTrackActionFailed

Raised when state track action (register/un-register tracking) fails

Event<ConnectionManager *, ConnectionManagerStatus> sp2plib::ConnectionManager::onStatusChange

Raised each time servers status changes

PeerConnectCallback sp2plib::ConnectionManager::PeerAccepted

Get of sets function pointer of type sp2plib::ConnectionManager::PeerConnect to call on peer acceptance as callback function


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