Symple module

Peer

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

Peer

#include <icy/symple/peer.h>

Inherits: Value

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

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.

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.
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()

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


Peer

Peer(const Peer & r)

Copy constructor; preserves type field.

Parameters

  • r Source peer.

operator=

Peer & operator=(const Peer & r)

Copy-assigns peer data from another peer.

Parameters

  • r Source peer.

Peer

Peer(const json::Value & r)

Constructs a peer from a raw JSON value.

Parameters

  • r JSON object containing peer fields.

address

const

Address address() const

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

Returns

Address constructed from the user and id fields.


id

const

std::string id() const

Returns the session ID assigned by the server.


user

const

std::string user() const

Returns the user identifier.


name

const

std::string name() const

Returns the display name.


type

const

std::string type() const

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


host

const

std::string host() const

Returns the host address associated with this peer.


setID

void setID(std::string_view id)

Sets the session ID field.

Parameters

  • id Session ID string.

setUser

void setUser(std::string_view user)

Sets the user identifier field.

Parameters

  • user User identifier string.

setName

void setName(std::string_view name)

Sets the display name field.

Parameters

  • name Display name string.

setType

void setType(std::string_view type)

Sets the peer type field.

Parameters

  • type Type string.

setHost

void setHost(std::string_view host)

Sets the host address field.

Parameters

  • host Host address string.

valid

virtual

virtual bool valid()

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

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

Parameters

  • os Output stream.

className

virtual const inline

virtual inline const char * className() const