Constructor
new Response(messageID, respHandler)
Parameters:
Name | Type | Description |
---|---|---|
messageID |
number | Message ID tied to the corresponding command request this is a response for. |
respHandler |
ResponseHandler | Function callback called on sending the response. |
- Source:
Methods
(static) fromPacket(data) → {Response
Converts a data packet into Response
.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array.<number, number, ?, ?> | A four element array where the elements, in sequence, signifies message type, message ID, error, and result. |
- Source:
Throws:
-
If the message type is not recognised.
- Type
- TypeError
Returns:
Representation of packet.
- Type
- Response
send()
Sends response using the response handler provided on construction.
- Source:
Throws:
-
If the response has already been sent.
- Type
- RangeError
sendConditionally(predicate)
Sends response conditionally, given a predicate.
Parameters:
Name | Type | Description |
---|---|---|
predicate |
function | A predicate taking a Response object and returning a boolean. |
- Source:
sendError(err)
Send error to client.
Turns the response into an error response, clears any previously set body data, and sends it using the response handler provided on construction.
Parameters:
Name | Type | Description |
---|---|---|
err |
Error | The Error instance to send. |
- Source:
Throws:
-
If err is not a
WebDriverError
, the error is propagated, i.e. rethrown. - Type
- Error
toPacket() → {Array}
Encodes the response to a packet.
- Source:
Returns:
Packet.
- Type
- Array