SNode.C
Loading...
Searching...
No Matches
web::websocket::server::SubProtocol Class Reference

#include <SubProtocol.h>

Inheritance diagram for web::websocket::server::SubProtocol:
Collaboration diagram for web::websocket::server::SubProtocol:

Public Member Functions

 ~SubProtocol () override
 
void subscribe (const std::string &group)
 
void sendBroadcast (const char *message, std::size_t messageLength, bool excludeSelf=false)
 
void sendBroadcast (const std::string &message, bool excludeSelf=false)
 
void sendBroadcastStart (const char *message, std::size_t messageLength, bool excludeSelf=false)
 
void sendBroadcastStart (const std::string &message, bool excludeSelf=false)
 
void sendBroadcastFrame (const char *message, std::size_t messageLength, bool excludeSelf=false)
 
void sendBroadcastFrame (const std::string &message, bool excludeSelf=false)
 
void sendBroadcastEnd (const char *message, std::size_t messageLength, bool excludeSelf=false)
 
void sendBroadcastEnd (const std::string &message, bool excludeSelf=false)
 
void forEachClient (const std::function< void(const SubProtocol *)> &sendToClient, bool excludeSelf=false)
 
- Public Member Functions inherited from web::websocket::SubProtocol< web::websocket::server::SocketContextUpgrade >
 SubProtocol (SubProtocol &)=delete
 
 SubProtocol (SubProtocol &&)=delete
 
SubProtocoloperator= (SubProtocol &)=delete
 
SubProtocoloperator= (SubProtocol &&)=delete
 
void sendMessage (const char *message, std::size_t messageLength) const
 
void sendMessage (const std::string &message) const
 
void sendMessageStart (const char *message, std::size_t messageLength) const
 
void sendMessageStart (const std::string &message) const
 
void sendMessageFrame (const char *message, std::size_t messageLength) const
 
void sendMessageFrame (const std::string &message) const
 
void sendMessageEnd (const char *message, std::size_t messageLength) const
 
void sendMessageEnd (const std::string &message) const
 
void sendPing (const char *reason=nullptr, std::size_t reasonLength=0) const
 
void sendClose (uint16_t statusCode=1000, const char *reason=nullptr, std::size_t reasonLength=0)
 
const std::string & getName ()
 
core::socket::stream::SocketConnectiongetSocketConnection () const
 

Protected Member Functions

 SubProtocol (SubProtocolContext *subProtocolContext, const std::string &name, int pingInterval=0, int maxFlyingPings=3)
 
- Protected Member Functions inherited from web::websocket::SubProtocol< web::websocket::server::SocketContextUpgrade >
 SubProtocol (SubProtocolContext *subProtocolContext, const std::string &name, int pingInterval=60, int maxFlyingPings=3)
 

Private Types

using Super = web::websocket::SubProtocol<web::websocket::server::SocketContextUpgrade>
 

Private Attributes

std::string group
 

Friends

template<typename RequestT , typename ResponseT , typename SubProtocolT >
class web::websocket::SocketContextUpgrade
 
class GroupsManager
 

Additional Inherited Members

- Protected Attributes inherited from web::websocket::SubProtocol< web::websocket::server::SocketContextUpgrade >
SubProtocolContextsubProtocolContext
 

Detailed Description

Definition at line 41 of file SubProtocol.h.

Member Typedef Documentation

◆ Super

Constructor & Destructor Documentation

◆ SubProtocol()

web::websocket::server::SubProtocol::SubProtocol ( SubProtocolContext * subProtocolContext,
const std::string & name,
int pingInterval = 0,
int maxFlyingPings = 3 )
protected

Definition at line 31 of file SubProtocol.cpp.

32 : Super(subProtocolContext, name, pingInterval, maxFlyingPings) {
34 }
void subscribe(SubProtocol *subProtocol, std::string group="")
web::websocket::SubProtocol< web::websocket::server::SocketContextUpgrade > Super
Definition SubProtocol.h:43

◆ ~SubProtocol()

web::websocket::server::SubProtocol::~SubProtocol ( )
overridevirtual

Reimplemented from web::websocket::SubProtocol< web::websocket::server::SocketContextUpgrade >.

Definition at line 36 of file SubProtocol.cpp.

36 {
38 }
void unsubscribe(SubProtocol *subProtocol)

Member Function Documentation

◆ forEachClient()

void web::websocket::server::SubProtocol::forEachClient ( const std::function< void(const SubProtocol *)> & sendToClient,
bool excludeSelf = false )

Definition at line 79 of file SubProtocol.cpp.

79 {
80 GroupsManager::instance()->forEachClient(group, sendToClient, excludeSelf ? this : nullptr);
81 }
void forEachClient(const std::string &group, const std::function< void(const SubProtocol *)> &sendToClient, const SubProtocol *excludedClient)

◆ sendBroadcast() [1/2]

void web::websocket::server::SubProtocol::sendBroadcast ( const char * message,
std::size_t messageLength,
bool excludeSelf = false )

Definition at line 51 of file SubProtocol.cpp.

51 {
52 GroupsManager::instance()->sendBroadcast(group, message, messageLength, excludeSelf ? this : nullptr);
53 }
void sendBroadcast(const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient)

◆ sendBroadcast() [2/2]

void web::websocket::server::SubProtocol::sendBroadcast ( const std::string & message,
bool excludeSelf = false )

Definition at line 47 of file SubProtocol.cpp.

47 {
48 GroupsManager::instance()->sendBroadcast(group, message, excludeSelf ? this : nullptr);
49 }

◆ sendBroadcastEnd() [1/2]

void web::websocket::server::SubProtocol::sendBroadcastEnd ( const char * message,
std::size_t messageLength,
bool excludeSelf = false )

Definition at line 71 of file SubProtocol.cpp.

71 {
72 GroupsManager::instance()->sendBroadcastEnd(group, message, messageLength, excludeSelf ? this : nullptr);
73 }
void sendBroadcastEnd(const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient)

◆ sendBroadcastEnd() [2/2]

void web::websocket::server::SubProtocol::sendBroadcastEnd ( const std::string & message,
bool excludeSelf = false )

Definition at line 75 of file SubProtocol.cpp.

75 {
76 GroupsManager::instance()->sendBroadcastEnd(group, message.data(), message.length(), excludeSelf ? this : nullptr);
77 }

◆ sendBroadcastFrame() [1/2]

void web::websocket::server::SubProtocol::sendBroadcastFrame ( const char * message,
std::size_t messageLength,
bool excludeSelf = false )

Definition at line 63 of file SubProtocol.cpp.

63 {
64 GroupsManager::instance()->sendBroadcastFrame(group, message, messageLength, excludeSelf ? this : nullptr);
65 }
void sendBroadcastFrame(const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient)

◆ sendBroadcastFrame() [2/2]

void web::websocket::server::SubProtocol::sendBroadcastFrame ( const std::string & message,
bool excludeSelf = false )

Definition at line 67 of file SubProtocol.cpp.

67 {
68 GroupsManager::instance()->sendBroadcastFrame(group, message.data(), message.length(), excludeSelf ? this : nullptr);
69 }

◆ sendBroadcastStart() [1/2]

void web::websocket::server::SubProtocol::sendBroadcastStart ( const char * message,
std::size_t messageLength,
bool excludeSelf = false )

Definition at line 55 of file SubProtocol.cpp.

55 {
56 GroupsManager::instance()->sendBroadcastStart(group, message, messageLength, excludeSelf ? this : nullptr);
57 }
void sendBroadcastStart(const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient)

◆ sendBroadcastStart() [2/2]

void web::websocket::server::SubProtocol::sendBroadcastStart ( const std::string & message,
bool excludeSelf = false )

Definition at line 59 of file SubProtocol.cpp.

59 {
60 GroupsManager::instance()->sendBroadcastStart(group, message, excludeSelf ? this : nullptr);
61 }

◆ subscribe()

void web::websocket::server::SubProtocol::subscribe ( const std::string & group)

Definition at line 40 of file SubProtocol.cpp.

40 {
42 // subscibe(group, this);
43 // unsubscribe(this->group, this);
44 // this->group = group;
45 }

Friends And Related Symbol Documentation

◆ GroupsManager

friend class GroupsManager
friend

Definition at line 82 of file SubProtocol.h.

◆ web::websocket::SocketContextUpgrade

template<typename RequestT , typename ResponseT , typename SubProtocolT >
friend class web::websocket::SocketContextUpgrade
friend

Definition at line 80 of file SubProtocol.h.

Member Data Documentation

◆ group

std::string web::websocket::server::SubProtocol::group
private

Definition at line 77 of file SubProtocol.h.

Referenced by web::websocket::server::GroupsManager::subscribe().


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