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::Peer Class Reference

Peer object More...

#include <Peer.h>

Public Member Functions

 Peer ()
 Initialises new instance of Peer class
 
 ~Peer ()
 Peer object destrictor
 
::std::string Get (::std::string name)
 Gets the value of custom property , equivalent is using operator [], variable = myPeer["some property"];
 
void Set (::std::string name,::std::string value)
 Sets value of custom property, equivalent is using operator [], myPeer["some property"] = "my value";
 
::std::string & operator[] (::std::string Name)
 Custom properties associated with Peer object. Note this: When serilized Object.ToString() is used, if you store complex object .ToString() usualy returns type name. XML serialization can be useful for transfering complex objects.
 
bool RemoveProperty (::std::string Name)
 Removes custom property from Peer object
 
int AllPropertiesCount ()
 Getas number of custom properties
 
::std::string PropertyNameOnIndex (int Index)
 Getas name of property on (name,vale) pair located at index postion
 
int GetSerializationLength (bool serializeCustomProperties=true)
 Calculates number of bytes needed in array to store serialization of peer object
 
unsigned char * new_GetBytes (int *len, bool serializeCustomProperties=true)
 Serialises object as byte array
 
int WriteBytes (unsigned char *buffer, int startIndex=0, bool serializeCustomProperties=true)
 Write peer object serialization to byte array buffer
 
int Parse (unsigned char *Data, int startIndex=0)
 Initialises object values form byte array
 
void ClearValues ()
 Clears all Peer object values.
 
bool IsEmpty ()
 Returns true if pper object is empty(clear) peer object
 

Static Public Member Functions

static Peer ParsePeer (unsigned char *Data, int startIndex=0, int *len=NULL)
 Creates Peer object from byte array containig peer object serialization with static alocation
 
static Peernew_ParsePeer (unsigned char *Data, int startIndex=0, int *len=NULL)
 Creates Peer object from byte array containig peer object serialization with dyanamic alocation
 

Public Attributes

Guid UID
 Unique identifier of peer
 
sp2plib::UInt32 State
 Gets or sets integer (sp2plib::UInt32) value representing status of peer, 0 (Peer.DisconnectedState) is reserved for disconnection, sp2plib::UInt32.MaxValue (Peer.AuthentificatedState) is state imediately after CP autentification other values can be used freely in aplications
 
Guid CheckPointUID
 Unique identifier of peer's CheckPoint server
 
STUN::NAT_Type NatType
 Gets or sets NAT behavior type of peer
 
int APIVersion
 Gets or sets API version. Do not set this yourself!
 
bool HasNUPnP
 Get or sets value indicating UPnP or NAT PNP presence in NAT device
 
bool CanTCPAccept
 Get or sets value indicating peer can do spcket::accept
 
IPEndPoint LocalEP
 Peer local end point
 
IPEndPoint PublicEP
 Peer's public end point
 
sp2plib::UInt64 LastActivityTime
 Reserved for managing object to keep track of last activity time of peer
 
Socket TunnelSocket
 Each managing class can use this property to assign, socket value for it's need. This property can not be serialised
 
IPEndPoint CheckPointEP
 IP end point of peer's checkpoint server
 
::std::string HostName
 Host name of peers machine. Max length is 255
 
::std::string OS
 Operating system name of peers machine. Max length is 255
 
Guid ApplicationUID
 Used to store UID application peer is using
 
::std::list< TunnelOpenMethod > NATTravMethodsUsed
 After NAT Traversal operation this member will be set as ordered list of tunnel methdos applyed during process. Last one will indicate final successful method. This property is valid only in Peer argument in successfull connect tunnel handler function
 
unsigned char TunnelSecretData [32]
 Set only when peer object is argument of tunnel open complete handler. It contains secret 32 byte array known only to peers on two tunnel sides. Array is generated by using data exchanged by Diffie–Hellman key exchange algoritham. Use of data is not strict. It can be used at will to generate further keys for encryption.
 

Static Public Attributes

static const sp2plib::UInt32 DisconnectedState = 0
 Constant equal to Peer disconnected state
 
static const sp2plib::UInt32 AuthentificatedState = 1
 Constant equal to Peer connected state, immediately after successfully session opening
 

Detailed Description

Peer object

Constructor & Destructor Documentation

sp2plib::Peer::Peer ( )

Initialises new instance of Peer class

sp2plib::Peer::~Peer ( )

Peer object destrictor

Member Function Documentation

int sp2plib::Peer::AllPropertiesCount ( )

Getas number of custom properties

void sp2plib::Peer::ClearValues ( )

Clears all Peer object values.

::std::string sp2plib::Peer::Get ( ::std::string  name)

Gets the value of custom property , equivalent is using operator [], variable = myPeer["some property"];

int sp2plib::Peer::GetSerializationLength ( bool  serializeCustomProperties = true)

Calculates number of bytes needed in array to store serialization of peer object

Parameters
serializeCustomPropertiesIndicates whether custom properties serialization shoud be calculated in
Returns
number of bytes needed to serialize peer object
bool sp2plib::Peer::IsEmpty ( )

Returns true if pper object is empty(clear) peer object

unsigned char* sp2plib::Peer::new_GetBytes ( int *  len,
bool  serializeCustomProperties = true 
)

Serialises object as byte array

Returns
Byte array serialization of Peer object
static Peer* sp2plib::Peer::new_ParsePeer ( unsigned char *  Data,
int  startIndex = 0,
int *  len = NULL 
)
static

Creates Peer object from byte array containig peer object serialization with dyanamic alocation

Parameters
Databyte array - serialized shape of Peer object
startIndexstart index of peer serialization
lenreturns total number of bytes parsed
Returns
Peer* - dinamicaly alocated, you will need to delite object returned by reference after use
::std::string& sp2plib::Peer::operator[] ( ::std::string  Name)

Custom properties associated with Peer object. Note this: When serilized Object.ToString() is used, if you store complex object .ToString() usualy returns type name. XML serialization can be useful for transfering complex objects.

Maximal lenght of serialized byte sequence of all custom properties is limited to 7000 bytes - this also includes lenght of property names! DO NOT USE THIS PROPERTIES TO TRANSFER LARGE DATA LIKE base64 image string or so!!!

Peer Peer1 = new Peer();
Peer1["Email"] = "someone@whatever.com";
...
Parameters
PropertyNameName of custom property. Max length 255 characters
Returns
Property value
int sp2plib::Peer::Parse ( unsigned char *  Data,
int  startIndex = 0 
)

Initialises object values form byte array

Parameters
Databyte array containing serialized shape of Peer object
static Peer sp2plib::Peer::ParsePeer ( unsigned char *  Data,
int  startIndex = 0,
int *  len = NULL 
)
static

Creates Peer object from byte array containig peer object serialization with static alocation

Parameters
Databyte array containing serialized shape of Peer object
startIndexstart index of peer serialization
lenreturns total number of bytes parsed
Returns
Peer* - staticaly alocated
::std::string sp2plib::Peer::PropertyNameOnIndex ( int  Index)

Getas name of property on (name,vale) pair located at index postion

bool sp2plib::Peer::RemoveProperty ( ::std::string  Name)

Removes custom property from Peer object

Returns
true if property was found and deleted
void sp2plib::Peer::Set ( ::std::string  name,
::std::string  value 
)

Sets value of custom property, equivalent is using operator [], myPeer["some property"] = "my value";

int sp2plib::Peer::WriteBytes ( unsigned char *  buffer,
int  startIndex = 0,
bool  serializeCustomProperties = true 
)

Write peer object serialization to byte array buffer

Parameters
bufferBuffer to write to. If null it will be inicialized with length to store peer serialization
startIndexStarting index from which to begin writing
serializeCustomPropertiesIndicates whether custom properties serialization shoud be done
Returns
Number or bytes writen

Member Data Documentation

int sp2plib::Peer::APIVersion

Gets or sets API version. Do not set this yourself!

Guid sp2plib::Peer::ApplicationUID

Used to store UID application peer is using

const sp2plib::UInt32 sp2plib::Peer::AuthentificatedState = 1
static

Constant equal to Peer connected state, immediately after successfully session opening

bool sp2plib::Peer::CanTCPAccept

Get or sets value indicating peer can do spcket::accept

IPEndPoint sp2plib::Peer::CheckPointEP

IP end point of peer's checkpoint server

Guid sp2plib::Peer::CheckPointUID

Unique identifier of peer's CheckPoint server

const sp2plib::UInt32 sp2plib::Peer::DisconnectedState = 0
static

Constant equal to Peer disconnected state

bool sp2plib::Peer::HasNUPnP

Get or sets value indicating UPnP or NAT PNP presence in NAT device

::std::string sp2plib::Peer::HostName

Host name of peers machine. Max length is 255

sp2plib::UInt64 sp2plib::Peer::LastActivityTime

Reserved for managing object to keep track of last activity time of peer

IPEndPoint sp2plib::Peer::LocalEP

Peer local end point

::std::list<TunnelOpenMethod> sp2plib::Peer::NATTravMethodsUsed

After NAT Traversal operation this member will be set as ordered list of tunnel methdos applyed during process. Last one will indicate final successful method. This property is valid only in Peer argument in successfull connect tunnel handler function

STUN::NAT_Type sp2plib::Peer::NatType

Gets or sets NAT behavior type of peer

::std::string sp2plib::Peer::OS

Operating system name of peers machine. Max length is 255

IPEndPoint sp2plib::Peer::PublicEP

Peer's public end point

sp2plib::UInt32 sp2plib::Peer::State

Gets or sets integer (sp2plib::UInt32) value representing status of peer, 0 (Peer.DisconnectedState) is reserved for disconnection, sp2plib::UInt32.MaxValue (Peer.AuthentificatedState) is state imediately after CP autentification other values can be used freely in aplications

unsigned char sp2plib::Peer::TunnelSecretData[32]

Set only when peer object is argument of tunnel open complete handler. It contains secret 32 byte array known only to peers on two tunnel sides. Array is generated by using data exchanged by Diffie–Hellman key exchange algoritham. Use of data is not strict. It can be used at will to generate further keys for encryption.

Socket sp2plib::Peer::TunnelSocket

Each managing class can use this property to assign, socket value for it's need. This property can not be serialised

Guid sp2plib::Peer::UID

Unique identifier of peer


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