269 timeout timeout_ms = DefaultTimeout;
279 static Sequence seq();
284 const DefaultTimeout = 15s;
287 const Version =
"1.6";
399 hash<auto>
connect(*hash<auto> opts, *reference<hash<auto>> info);
454 nothing
setWarningQueue(
int warning_ms,
int warning_bs, Queue queue,
auto arg, timeout min_ms = 1s);
526 disconnectUnlocked(
int cmd = WSCC_GoingAway);
531 eventLoop(code callback);
536 receivedPong(*data msg);
541 handlePing(hash<auto> h);
551 logError(
string fmt);
556 logDebug(
string fmt);
561 sendClose(
int code, *
string txtmsg);
566 hash<auto> connectUnlocked(*hash<auto> hdr0, *reference<hash<auto>> info);
601 send(data msg,
int op,
bool fin);
625 "cls": Class::forName(
"WebSocketConnectionObject"),
626 "options": HttpConnection::ConnectionScheme.options,
640 constructor(
string name,
string description,
string url, hash<auto> attributes = {}, hash<auto> options = {})
660 hash<PingInfo> pingIntern(hash<PingInfo> rv);
717 "supports_children": True,
718 "supports_observable": True,
719 "supports_messages": MSG_Async,
720 "children_can_support_apis": True,
722 "desc":
"Allows sending and receiving WebSocket messages to and from a WebSocket server",
727 "connect_timeout": <DataProviderOptionInfo>{
728 "type": AbstractDataProviderTypeMap.
"int",
729 "desc":
"connection timeout to use in milliseconds",
731 "data": <DataProviderOptionInfo>{
732 "type": AbstractDataProviderTypeMap.
"string",
733 "desc":
"data serialization to use:\n"
735 " - `json`: JSON serialization (default)\n"
738 " - `yaml`: YAML serialization\n"
740 " - `none`: no serialization; raw messages\n",
749 "headers": <DataProviderOptionInfo>{
750 "type": AbstractDataProviderTypeMap.
"hash",
751 "desc":
"headers to add in each outgoing request",
753 "http_version": <DataProviderOptionInfo>{
754 "type": AbstractDataProviderTypeMap.
"string",
755 "desc":
"HTTP version to use (`1.0` or `1.1`, defaults to `1.1`)",
756 "default_value":
"1.1",
758 "max_redirects": <DataProviderOptionInfo>{
759 "type": AbstractDataProviderTypeMap.
"int",
760 "desc":
"maximum redirects to support",
762 "proxy": <DataProviderOptionInfo>{
763 "type": AbstractDataProviderTypeMap.
"string",
764 "desc":
"proxy URL to use",
766 "report_pings": <DataProviderOptionInfo>{
767 "type": AbstractDataProviderTypeMap.
"bool",
768 "desc":
"Raise events for ping message from clients",
769 "default_value": False,
771 "timeout": <DataProviderOptionInfo>{
772 "type": AbstractDataProviderTypeMap.
"int",
773 "desc":
"transfer timeout to use in milliseconds",
775 "url": <DataProviderOptionInfo>{
776 "type": AbstractDataProviderTypeMap.
"string",
777 "desc":
"A URL for a WebSocket connection",
784 "wait-for-message": Class::forName(
"WebSocketClientWaitForMessageDataProvider"),
933 "type":
"WebSocketClientDataProvider",
945 hash<DataProviderInfo> getStaticInfoImpl();
960 "type":
"WebSocketClientDelayedDataProvider",
978 hash<DataProviderInfo> getStaticInfoImpl();
998 "type":
"WebSocketClientWaitForMessageDataProvider",
999 "supports_request": True,
1000 "desc":
"Waits for a WebSocket message to be received from the server within a timeout period and "
1001 "returns the message if one is received in the timeout perdiod, or an exception is thrown",
1067 "desc":
"The number of milliseconds to wait for an incoming message; after this point, if no "
1068 "WebSocket message has been received, an exception will be thrown",
1070 "default_value": 10000,
1085 static Class
cls =
new Class(
"WebSocketClientDelayedDataProvider");
1090 "desc":
"WebSocket client data provider factory",
1091 "children_can_support_observers": True,
1092 "children_can_support_messages": True,
Event- and message-based data provider for WebSocket client-side events.
Definition: WebSocketClient.qm.dox.h:712
Queue getQueue()
Returs the child message queue.
constructor(*hash< auto > options)
Creates the object from constructor options.
const ConstructorOptions
Constructor options.
Definition: WebSocketClient.qm.dox.h:726
unsupportedSerialization()
Throws an UNSUPPORTED-SERIALIZATION error.
deregister()
Dergister a child data provider.
string serialization
Data serialization.
Definition: WebSocketClient.qm.dox.h:796
const ProviderInfo
Provider info.
Definition: WebSocketClient.qm.dox.h:716
bool report_pings
report pings
Definition: WebSocketClient.qm.dox.h:799
WebSocketClient client
The web socket client itself.
Definition: WebSocketClient.qm.dox.h:793
*list< string > getChildProviderNamesImpl()
Returns a list of child data provider names.
hash< string, hash< DataProviderMessageInfo > > getEventTypesImpl()
Returns a hash of all supported event types.
WebSocketClientWaitForMessageDataProvider child
Wait for message API data provider.
Definition: WebSocketClient.qm.dox.h:805
sendMessageImpl(string message_id, auto msg, *hash< auto > send_message_options)
Sends a message from message-capable data providers.
const SerializationMap
Set of serialization options as a hash.
Definition: WebSocketClient.qm.dox.h:788
auto deserializeMessage(data msg)
Deserializes the message.
event(*data msg)
Called when a WebSocket event arrives.
abstract notifyObservers(string msg_id, hash< auto > event)
For WS event notifications.
Mutex m()
Mutex for wait for message child data provider handling.
data serializeMessage(auto msg)
Serializes the message for sending.
const ApiClasses
Registered API classes.
Definition: WebSocketClient.qm.dox.h:783
Queue q
Child message queue.
Definition: WebSocketClient.qm.dox.h:808
pong(*data msg)
Got a pong message.
*AbstractDataProvider getChildProviderImpl(string name)
Returns the given child provider or NOTHING if the given child is unknown.
hash< string, hash< DataProviderMessageInfo > > getMessageTypesImpl()
Returns the description of an outbound message, if any.
static hash< auto > getOptionsFromTemplate(hash< auto > template_options, *hash< auto > options)
Returns options from a template.
start()
Connects and starts receiving messages.
The WebSocket data provider factory.
Definition: WebSocketClient.qm.dox.h:1080
static Class cls
Data provider type info.
Definition: WebSocketClient.qm.dox.h:1085
hash< DataProviderInfo > getProviderInfoImpl()
Returns static provider information.
const FactoryInfo
Factory info.
Definition: WebSocketClient.qm.dox.h:1088
Class getClassImpl()
Returns the class for the data provider object.
hash< DataProviderFactoryInfo > getInfoImpl()
Returns static factory information without provider_info.
Event-based data provider for WebSocket messaging.
Definition: WebSocketClient.qm.dox.h:928
constructor(hash< auto > template_options, *hash< auto > options)
Creates the object from constructor + template options.
const ProviderInfo
Provider info.
Definition: WebSocketClient.qm.dox.h:932
constructor(*hash< auto > options)
Creates the object from constructor options.
Event-based data provider for WebSocket messaging.
Definition: WebSocketClient.qm.dox.h:955
const ProviderInfo
Provider info.
Definition: WebSocketClient.qm.dox.h:959
observersReady()
Called when all observers have been added to the object.
constructor(hash< auto > template_options, *hash< auto > options)
Creates the object from constructor + template options.
constructor(*hash< auto > options)
Creates the object from constructor options.
WebSocket event data description.
Definition: WebSocketClient.qm.dox.h:984
constructor()
Creates the type.
bool isOpen()
returns True if the connection is currently open and active, False if not
string getUrl()
returns the URL given in the constructor
setEventQueue()
Removes any Queue object so that socket events are no longer added to the Queue.
constructor(code cb, hash< auto > opts)
creates the object and optionally sets logging targets
clearStats()
Clears performance statistics.
*code yield
callable object to yield the current thread's execution
Definition: WebSocketClient.qm.dox.h:275
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
destructor()
disconnects the connection and stops the event thread if connected
setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data)
Sets a Queue object to receive socket events.
int tid
TID of the event thread.
Definition: WebSocketClient.qm.dox.h:271
pong(*data msg)
Sends a PONG message to the server as a unidirectional keep-alive message.
hash< auto > getSchemes()
returns a hash of URL scheme information for URL schemes supported by this object
string getSafeUrl()
Returns a "safe" URL, without any password info.
ping(*data msg)
Sends a PING message to the server as a unidirectional keep-alive message.
const Version
module version
Definition: WebSocketClient.qm.dox.h:287
send(string str)
Sends string data over the web socket with timeout specified in options; if any errors occur,...
int getConnectionId()
returns the unique connection ID
string url
URL string.
Definition: WebSocketClient.qm.dox.h:277
disconnect(int cmd=WSCC_GoingAway)
disconnect with the given close code
hash< auto > getUsageInfo()
Returns performance statistics for the socket.
send(data msg, int op, bool fin)
pushes an unencoded message on the connection's message queue; the message will be encoded with WebSo...
send(binary bin)
Sends binary data over the web socket with timeout specified in options; if any errors occur,...
hash< auto > connect(*hash< auto > opts, *reference< hash< auto > > info)
connects to the websocket server
WebSocket client wait for message from server API data provider.
Definition: WebSocketClient.qm.dox.h:993
const RequestType
Request type.
Definition: WebSocketClient.qm.dox.h:1005
auto doRequestImpl(auto req, *hash< auto > request_options)
Makes a request and returns the response.
destructor()
Deletes the object.
hash< DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
string getName()
Returns the data provider name.
const ProviderInfo
Provider info.
Definition: WebSocketClient.qm.dox.h:997
*AbstractDataProviderType getResponseTypeImpl()
Returns the description of a response message, if this object represents a response message.
const ResponseType
Response type.
Definition: WebSocketClient.qm.dox.h:1008
constructor(WebSocketClientDataProviderBase base)
Creates the object.
*AbstractDataProviderType getRequestTypeImpl()
Returns the description of a successful request message, if any.
Data type for delete order calls.
Definition: WebSocketClient.qm.dox.h:1060
constructor()
Creates the object.
const Fields
Field descriptions.
Definition: WebSocketClient.qm.dox.h:1064
class for websocket connections; returns an object of class WebSocketClient for receiving websocket e...
Definition: WebSocketClient.qm.dox.h:620
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
constructor(string name, string description, string url, hash< auto > attributes={}, hash< auto > options={})
creates the WebSocketConnectionObject connection object
const ConnectionScheme
Connection entry info.
Definition: WebSocketClient.qm.dox.h:624
setChildCapabilities()
Sets child data provider capabilities.
DataProvider::AbstractDataProvider getDataProvider()
returns an WebSocketClientDataProvider object for this connection
bool hasDataProvider()
returns True, as the connection returns a data provider with the getDataProvider() method
WebSocketClient getImpl(bool connect=True, *hash< auto > rtopts)
returns a WebSocketClient object
*hash< auto > getRuntimeOptions()
returns runtime options
string getType()
returns "ws"
const WSC_Break
If the client should stop listening (message already processed)
Definition: WebSocketClient.qm.dox.h:200
const WSC_Continue
If the client should continue listening (message already processed)
Definition: WebSocketClient.qm.dox.h:197
const WSC_Process
Definition: WebSocketClient.qm.dox.h:194
the WebSocketClient namespace contains all the definitions in the WebSocketClient module
Definition: WebSocketClient.qm.dox.h:179
const MESSAGE_WS_RAW
WebSocket raw data message type.
Definition: WebSocketClient.qm.dox.h:227
const EVENT_WS_DATA
WebSocket data event constant.
Definition: WebSocketClient.qm.dox.h:207
const MESSAGE_WS_PONG
WebSocket pong message type.
Definition: WebSocketClient.qm.dox.h:237
const EVENT_WS_PING
WebSocket ping event constant.
Definition: WebSocketClient.qm.dox.h:210
const MESSAGE_WS_DATA
WebSocket data message type.
Definition: WebSocketClient.qm.dox.h:222
const WsSchemes
known websocket schemes
Definition: WebSocketClient.qm.dox.h:181
const EVENT_WS_CLOSED
WebSocket connection closed event constant.
Definition: WebSocketClient.qm.dox.h:216
const WsDefaultPort
default port for connections
Definition: WebSocketClient.qm.dox.h:204
const EVENT_WS_PONG
WebSocket pong event constant.
Definition: WebSocketClient.qm.dox.h:213
const MESSAGE_WS_PING
WebSocket ping message type.
Definition: WebSocketClient.qm.dox.h:232