Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::MessageChannelHandler Class Reference

Manages channels for exchanging messages between peers. More...

#include <message_channel_handler.h>

Inheritance diagram for jami::MessageChannelHandler:
Inheritance graph
Collaboration diagram for jami::MessageChannelHandler:
Collaboration graph

Classes

struct  Impl
 
struct  Message
 

Public Types

using OnMessage = std::function< void(const std::shared_ptr< dht::crypto::Certificate > &, std::string &, const std::string &)>
 
using OnPeerStateChanged = std::function< void(const std::string &, bool)>
 

Public Member Functions

void closeChannel (const std::string &peer, const DeviceId &device, const std::shared_ptr< dhtnet::ChannelSocket > &conn)
 
void connect (const DeviceId &deviceId, const std::string &, ConnectCb &&cb, const std::string &connectionType, bool forceNewConnection=false) override
 Ask for a new message channel.
 
std::shared_ptr< dhtnet::ChannelSocket > getChannel (const std::string &peer, const DeviceId &deviceId) const
 
std::vector< std::shared_ptr< dhtnet::ChannelSocket > > getChannels (const std::string &peer) const
 
 MessageChannelHandler (dhtnet::ConnectionManager &cm, OnMessage onMessage, OnPeerStateChanged onPeer)
 
void onReady (const std::shared_ptr< dht::crypto::Certificate > &peer, const std::string &name, std::shared_ptr< dhtnet::ChannelSocket > channel) override
 Launch message process.
 
bool onRequest (const std::shared_ptr< dht::crypto::Certificate > &peer, const std::string &name) override
 Determine if we accept or not the message request.
 
 ~MessageChannelHandler ()
 
- Public Member Functions inherited from jami::ChannelHandlerInterface
virtual void connect (const dht::InfoHash &, const std::string &, ConnectCallbackLegacy &&)
 
virtual ~ChannelHandlerInterface ()
 

Static Public Member Functions

static bool sendMessage (const std::shared_ptr< dhtnet::ChannelSocket > &, const Message &message)
 

Detailed Description

Manages channels for exchanging messages between peers.

Definition at line 28 of file message_channel_handler.h.

Member Typedef Documentation

◆ OnMessage

using jami::MessageChannelHandler::OnMessage = std::function<void(const std::shared_ptr<dht::crypto::Certificate>&, std::string&, const std::string&)>

Definition at line 31 of file message_channel_handler.h.

◆ OnPeerStateChanged

Definition at line 32 of file message_channel_handler.h.

Constructor & Destructor Documentation

◆ MessageChannelHandler()

jami::MessageChannelHandler::MessageChannelHandler ( dhtnet::ConnectionManager &  cm,
OnMessage  onMessage,
OnPeerStateChanged  onPeer 
)

Definition at line 44 of file message_channel_handler.cpp.

◆ ~MessageChannelHandler()

jami::MessageChannelHandler::~MessageChannelHandler ( )

Definition at line 50 of file message_channel_handler.cpp.

Member Function Documentation

◆ closeChannel()

void jami::MessageChannelHandler::closeChannel ( const std::string &  peer,
const DeviceId device,
const std::shared_ptr< dhtnet::ChannelSocket > &  conn 
)

Definition at line 193 of file message_channel_handler.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ connect()

void jami::MessageChannelHandler::connect ( const DeviceId deviceId,
const std::string &  ,
ConnectCb &&  cb,
const std::string &  connectionType,
bool  forceNewConnection = false 
)
overridevirtual

Ask for a new message channel.

Parameters
deviceIdThe device to connect
name(Unused, generated from deviceId)
cbThe callback to call when connected (can be immediate if already connected)
connectionTypefor iOS notifications
forceNewConnectionIf we want a new SIP connection

Implements jami::ChannelHandlerInterface.

Definition at line 53 of file message_channel_handler.cpp.

References jami::emitSignal(), JAMI_LOG, and MESSAGE_SCHEME.

Here is the call graph for this function:

◆ getChannel()

std::shared_ptr< dhtnet::ChannelSocket > jami::MessageChannelHandler::getChannel ( const std::string &  peer,
const DeviceId deviceId 
) const

Definition at line 98 of file message_channel_handler.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getChannels()

std::vector< std::shared_ptr< dhtnet::ChannelSocket > > jami::MessageChannelHandler::getChannels ( const std::string &  peer) const

Definition at line 113 of file message_channel_handler.cpp.

References jami::emitSignal().

Referenced by jami::JamiAccount::sendPresenceNote().

Here is the call graph for this function:

◆ onReady()

void jami::MessageChannelHandler::onReady ( const std::shared_ptr< dht::crypto::Certificate > &  peer,
const std::string &  name,
std::shared_ptr< dhtnet::ChannelSocket >  channel 
)
overridevirtual

Launch message process.

Parameters
deviceIdDevice who asked
nameName asked
channelChannel used to message

Implements jami::ChannelHandlerInterface.

Definition at line 139 of file message_channel_handler.cpp.

References jami::emitSignal(), and JAMI_WARNING.

Here is the call graph for this function:

◆ onRequest()

bool jami::MessageChannelHandler::onRequest ( const std::shared_ptr< dht::crypto::Certificate > &  peer,
const std::string &  name 
)
overridevirtual

Determine if we accept or not the message request.

Parameters
deviceIdDevice who asked
nameName asked
Returns
if the channel is for a valid conversation and device not banned

Implements jami::ChannelHandlerInterface.

Definition at line 130 of file message_channel_handler.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ sendMessage()

bool jami::MessageChannelHandler::sendMessage ( const std::shared_ptr< dhtnet::ChannelSocket > &  socket,
const Message message 
)
static

Definition at line 217 of file message_channel_handler.cpp.

References jami::emitSignal(), and JAMI_WARNING.

Here is the call graph for this function:

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