Class luasql.exasol.WebsocketDatahandler
This internal class is registered as a callback for incoming messages when connecting to a websocket.
It collects incoming messages and logs warnings in case a websocket error occurs.
Local Functions
luasql.exasol.websocketdatahandler.is_websocket_error(opcode) | Checks if the given websocket opcode represents an error or not. |
Methods
luasql.exasol.websocketdatahandler:create() | Create a new instance of the WebsocketDatahandler class. |
luasql.exasol.websocketdatahandler:handle_data(conn, opcode, message) | Callback function for handling data received from a websocket. |
luasql.exasol.websocketdatahandler:expect_data() | Tell this handler that we are expecting incoming data, e.g. |
luasql.exasol.websocketdatahandler:expected_data_received() | Tell this handler hat we have received the expected data, e.g. |
luasql.exasol.websocketdatahandler:get_data() | Get all message data collected by this handler. |
luasql.exasol.websocketdatahandler:has_received_data() | Check if this handler has received any data. |
Local Functions
Methods- luasql.exasol.websocketdatahandler.is_websocket_error(opcode) line 24
-
Checks if the given websocket opcode represents an error or not.
Parameters:
- opcode boolean or number the received websocket opcode
Returns:
-
boolean
true
if the opcode represents an error that should be logged
Methods
- luasql.exasol.websocketdatahandler:create() line 14
-
Create a new instance of the WebsocketDatahandler class.
Returns:
-
luasql.exasol.WebsocketDatahandler
a new instance
- luasql.exasol.websocketdatahandler:handle_data(conn, opcode, message) line 37
-
Callback function for handling data received from a websocket. This method collects valid
data in a list and logs and logs a warning in case an error was received.
Parameters:
- conn table the websocket connection
- opcode boolean or number the websocket opcode. See RFC 6455 for details about opcodes
- message string the received message
Raises:
an error in case we where not expecting to receive any data - luasql.exasol.websocketdatahandler:expect_data() line 56
- Tell this handler that we are expecting incoming data, e.g. if we are waiting for a response after sending a request. This also resets the collected data to start a fresh collection.
- luasql.exasol.websocketdatahandler:expected_data_received() line 64
- Tell this handler hat we have received the expected data, e.g. when the response for a request has been received.
- luasql.exasol.websocketdatahandler:get_data() line 71
-
Get all message data collected by this handler.
Returns:
-
string or nil
the concatenated received messages or
nil
if no message was received - luasql.exasol.websocketdatahandler:has_received_data() line 82
-
Check if this handler has received any data.
Returns:
-
boolean
true
if at least one message was received