Symple module

Peer

Symple peer record containing identity, presence, and custom fields.

#include <icy/symple/peer.h>

class Peer

Defined in src/symple/include/icy/symple/peer.h:30

Inherits
Value

A Peer object may also contain arbitrary application data set by the client to share with other peers on the network. See also: Address for further methods and basic accessors.

Friends

NameDescription
operator<< inline

operator<<

inline

friend inline std::ostream & operator<<(std::ostream & os, const Peer & peer)

Defined in src/symple/include/icy/symple/peer.h:101

Public Methods

ReturnNameDescription
PeerConstructs an empty peer with type set to "Peer".
PeerCopy constructor; preserves type field.
Peer &operator=Copy-assigns peer data from another peer.
PeerConstructs a peer from a raw JSON value.
~Peer virtual
Addressaddress constReturns the peer's address (user + session ID).
std::stringid constReturns the session ID assigned by the server.
std::stringuser constReturns the user identifier.
std::stringname constReturns the display name.
std::stringtype constReturns the peer type string (e.g. "Peer", "bot").
std::stringhost constReturns the host address associated with this peer.
voidsetIDSets the session ID field.
voidsetUserSets the user identifier field.
voidsetNameSets the display name field.
voidsetTypeSets the peer type field.
voidsetHostSets the host address field.
boolvalid virtualUpdates the peer from the given data object.
voidprint constWrites the peer's JSON representation to the given stream.
const char *className virtual const inline

Peer

Peer()

Defined in src/symple/include/icy/symple/peer.h:34

Constructs an empty peer with type set to "Peer".


Peer

Peer(const Peer & r)

Defined in src/symple/include/icy/symple/peer.h:38

Copy constructor; preserves type field.

Parameters

ParameterTypeDescription
rconst Peer &Source peer.

operator=

Peer & operator=(const Peer & r)

Defined in src/symple/include/icy/symple/peer.h:42

Copy-assigns peer data from another peer.

Parameters

ParameterTypeDescription
rconst Peer &Source peer.

Peer

Peer(const json::Value & r)

Defined in src/symple/include/icy/symple/peer.h:46

Constructs a peer from a raw JSON value.

Parameters

ParameterTypeDescription
rconst json::Value &JSON object containing peer fields.

~Peer

virtual

virtual ~Peer()

Defined in src/symple/include/icy/symple/peer.h:48


address

const

Address address() const

Defined in src/symple/include/icy/symple/peer.h:52

Returns the peer's address (user + session ID).

Returns

Address constructed from the user and id fields.


id

const

std::string id() const

Defined in src/symple/include/icy/symple/peer.h:55

Returns the session ID assigned by the server.


user

const

std::string user() const

Defined in src/symple/include/icy/symple/peer.h:58

Returns the user identifier.


name

const

std::string name() const

Defined in src/symple/include/icy/symple/peer.h:61

Returns the display name.


type

const

std::string type() const

Defined in src/symple/include/icy/symple/peer.h:65

Returns the peer type string (e.g. "Peer", "bot").


host

const

std::string host() const

Defined in src/symple/include/icy/symple/peer.h:68

Returns the host address associated with this peer.


setID

void setID(std::string_view id)

Defined in src/symple/include/icy/symple/peer.h:72

Sets the session ID field.

Parameters

ParameterTypeDescription
idstd::string_viewSession ID string.

setUser

void setUser(std::string_view user)

Defined in src/symple/include/icy/symple/peer.h:76

Sets the user identifier field.

Parameters

ParameterTypeDescription
userstd::string_viewUser identifier string.

setName

void setName(std::string_view name)

Defined in src/symple/include/icy/symple/peer.h:80

Sets the display name field.

Parameters

ParameterTypeDescription
namestd::string_viewDisplay name string.

setType

void setType(std::string_view type)

Defined in src/symple/include/icy/symple/peer.h:85

Sets the peer type field.

Parameters

ParameterTypeDescription
typestd::string_viewType string.

setHost

void setHost(std::string_view host)

Defined in src/symple/include/icy/symple/peer.h:89

Sets the host address field.

Parameters

ParameterTypeDescription
hoststd::string_viewHost address string.

valid

virtual

virtual bool valid()

Defined in src/symple/include/icy/symple/peer.h:95

Updates the peer from the given data object.

Returns true if the peer has id, user, and type fields.


print

const

void print(std::ostream & os) const

Defined in src/symple/include/icy/symple/peer.h:99

Writes the peer's JSON representation to the given stream.

Parameters

ParameterTypeDescription
osstd::ostream &Output stream.

className

virtual const inline

virtual inline const char * className() const

Defined in src/symple/include/icy/symple/peer.h:107