|
AGXDynamics
2.31.1.0
|
A socket that connects to a client. More...
#include <WebSocket.h>
Inheritance diagram for agxNet::WebSocket:Public Types | |
| enum | ContentType { CONTENT_BINARY, CONTENT_TEXT } |
| typedef agx::observer_ptr < const ControlChannel > | ControlChannelConstObserver |
| typedef agx::ref_ptr< const ControlChannel > | ControlChannelConstRef |
| typedef agx::observer_ptr < ControlChannel > | ControlChannelObserver |
| typedef agx::ref_ptr < ControlChannel > | ControlChannelRef |
| typedef agx::Callback3 < ControlChannel *, agxNet::WebSocket *, agxNet::StructuredMessage * > | MessageHandler |
| typedef agx::observer_ptr < const Packet > | PacketConstObserver |
| typedef agx::ref_ptr< const Packet > | PacketConstRef |
| typedef agx::observer_ptr< Packet > | PacketObserver |
| typedef agx::ref_ptr< Packet > | PacketRef |
| typedef agx::Callback3 < WebSocket *, agx::UInt8 *, size_t > | ReceiveCallback |
| A callback function that is run when a message is received from the socket. More... | |
| typedef agx::Event2 < ControlChannel *, agxNet::WebSocket * > | SocketEvent |
Public Member Functions | |
| AGX_DECLARE_VECTOR_TYPES (Packet) | |
| template<typename T > | |
| T * | as () |
| Subclass casting. More... | |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| T * | asSafe () |
| Safe subclass casting, return nullptr if template type does not match. More... | |
| template<typename T > | |
| const T * | asSafe () const |
| ControlChannel (agx::UInt16 port, const agx::String &token="") | |
| ControlChannel (agxNet::PortRange *portRange, const agx::String &token="") | |
| agxNet::WebSocket * | createConnection (const agx::String &address, agx::UInt16 port, bool useSSL=false, const agx::String &path="/", const agx::String &protocol="agx_stream", bool isAnonymous=false) |
| ContentType | getContentType () const |
| int | getLibwebsocketsWriteProtocol () const |
| agx::UInt8 * | getPayload () |
| Returns a pointer to the data this Packet contains. More... | |
| agx::UInt16 | getPort () const |
| int | getReferenceCount () const |
| size_t | getSize () const |
| template<typename T > | |
| bool | is () const |
| Subclass test. More... | |
| bool | isAnonymous () const |
| bool | isAuthenticated () const |
| void | messageReceived (void *message, size_t size) |
| Packet (size_t size, ContentType type) | |
| Packet (const agx::String &message) | |
| Packet (const agxJson::Value &message) | |
| Packet (const agxData::Frame *frame) | |
| void | reference (void *ptr=nullptr) const |
| Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More... | |
| void | registerMessageHandler (const agx::String &uri, MessageHandler callback) |
| void | send (const agx::String &message) |
| Send the content of the given packet to the client. More... | |
| void | send (Packet *packet) |
| void | send (const StructuredMessage *message) |
| void | send (const StructuredMessage *message) |
| bool | service (agx::Real timeoutMs=0) |
| void | setAnonymous (bool flag) |
| void | setAuthenticated (bool flag) |
| void | setReceiveCallback (ReceiveCallback callback) |
| Set the callback function that should be called when new messages are received. More... | |
| void | unreference (void *ptr=nullptr) const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
| void | unreference_nodelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
Static Public Member Functions | |
| template<typename T > | |
| static bool | ValidateCast (const Referenced *object) |
Public Attributes | |
| SocketEvent | socketConnectEvent |
| SocketEvent | socketDisconnectEvent |
Protected Member Functions | |
| virtual | ~ControlChannel () |
| virtual | ~Packet () |
| virtual | ~WebSocket () |
| void | allocateObserverVector () const |
| void | deleteUsingDeleteHandler () const |
Static Protected Member Functions | |
| static DeleteHandler * | getDeleteHandler () |
| static void | setDeleteHandler (DeleteHandler *handler) |
| Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More... | |
Protected Attributes | |
| Mutex | m_mutex |
| ObserverContainer | m_observers |
| AtomicValue | m_refCount |
A socket that connects to a client.
ControlChannel.
Instances of this class is created by the Socket server when a new client connects.
Definition at line 54 of file WebSocket.h.
Definition at line 60 of file WebSocket.h.
| typedef agx::ref_ptr< const ControlChannel > agxNet::WebSocket::ControlChannelConstRef |
Definition at line 60 of file WebSocket.h.
Definition at line 60 of file WebSocket.h.
Definition at line 60 of file WebSocket.h.
| typedef agx::Callback3<ControlChannel *, agxNet::WebSocket *, agxNet::StructuredMessage *> agxNet::WebSocket::MessageHandler |
Definition at line 297 of file WebSocket.h.
| typedef agx::observer_ptr< const Packet > agxNet::WebSocket::PacketConstObserver |
Definition at line 58 of file WebSocket.h.
| typedef agx::ref_ptr< const Packet > agxNet::WebSocket::PacketConstRef |
Definition at line 58 of file WebSocket.h.
Definition at line 58 of file WebSocket.h.
| typedef agx::ref_ptr< Packet > agxNet::WebSocket::PacketRef |
Definition at line 58 of file WebSocket.h.
| typedef agx::Callback3<WebSocket *, agx::UInt8*, size_t> agxNet::WebSocket::ReceiveCallback |
A callback function that is run when a message is received from the socket.
The first argument is the WebSocket that received them message, the second is a pointer pointing to the received message and the third argument is the size of the message in bytes.
Definition at line 70 of file WebSocket.h.
Definition at line 281 of file WebSocket.h.
| Enumerator | |
|---|---|
| CONTENT_BINARY | |
| CONTENT_TEXT | |
Definition at line 136 of file WebSocket.h.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
| agxNet::WebSocket::AGX_DECLARE_VECTOR_TYPES | ( | Packet | ) |
|
protectedinherited |
|
inherited |
Subclass casting.
Template type must match actual type, dynamic_cast assertion will fail otherwise.
Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().
|
inherited |
|
inherited |
Safe subclass casting, return nullptr if template type does not match.
Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().
|
inherited |
| agxNet::WebSocket::ControlChannel | ( | agx::UInt16 | port, |
| const agx::String & | token = "" |
||
| ) |
| agxNet::WebSocket::ControlChannel | ( | agxNet::PortRange * | portRange, |
| const agx::String & | token = "" |
||
| ) |
| agxNet::WebSocket* agxNet::WebSocket::createConnection | ( | const agx::String & | address, |
| agx::UInt16 | port, | ||
| bool | useSSL = false, |
||
| const agx::String & | path = "/", |
||
| const agx::String & | protocol = "agx_stream", |
||
| bool | isAnonymous = false |
||
| ) |
|
protectedinherited |
| ContentType agxNet::WebSocket::getContentType | ( | ) | const |
|
staticprotectedinherited |
| int agxNet::WebSocket::getLibwebsocketsWriteProtocol | ( | ) | const |
| agx::UInt8* agxNet::WebSocket::getPayload | ( | ) |
Returns a pointer to the data this Packet contains.
Senders should write their message to this memory area.
| agx::UInt16 agxNet::WebSocket::getPort | ( | ) | const |
|
inherited |
| size_t agxNet::WebSocket::getSize | ( | ) | const |
|
inherited |
Subclass test.
Referenced by agx::Object::getAutoScopedResource(), agxData::Buffer::getElement(), and agx::Object::getResource().
| bool agxNet::WebSocket::isAnonymous | ( | ) | const |
| bool agxNet::WebSocket::isAuthenticated | ( | ) | const |
| agxNet::WebSocket::Packet | ( | size_t | size, |
| ContentType | type | ||
| ) |
| agxNet::WebSocket::Packet | ( | const agx::String & | message | ) |
| agxNet::WebSocket::Packet | ( | const agxJson::Value & | message | ) |
| agxNet::WebSocket::Packet | ( | const agxData::Frame * | frame | ) |
Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
This method should be used with care, always balanced with the same number of calls to unreference.
Referenced by agxData::Val< UInt >::Val().
| void agxNet::WebSocket::registerMessageHandler | ( | const agx::String & | uri, |
| MessageHandler | callback | ||
| ) |
| void agxNet::WebSocket::send | ( | const agx::String & | message | ) |
Send the content of the given packet to the client.
| void agxNet::WebSocket::send | ( | const StructuredMessage * | message | ) |
| void agxNet::WebSocket::send | ( | const StructuredMessage * | message | ) |
| bool agxNet::WebSocket::service | ( | agx::Real | timeoutMs = 0 | ) |
| void agxNet::WebSocket::setAnonymous | ( | bool | flag | ) |
| void agxNet::WebSocket::setAuthenticated | ( | bool | flag | ) |
|
staticprotectedinherited |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
| void agxNet::WebSocket::setReceiveCallback | ( | ReceiveCallback | callback | ) |
Set the callback function that should be called when new messages are received.
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.
This method should be used with care, always balanced with the same number of calls to reference.
|
inherited |
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.
|
staticinherited |
|
mutableprotectedinherited |
Definition at line 240 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 239 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 241 of file Referenced.h.
| SocketEvent agxNet::WebSocket::socketConnectEvent |
Definition at line 283 of file WebSocket.h.
| SocketEvent agxNet::WebSocket::socketDisconnectEvent |
Definition at line 284 of file WebSocket.h.