Constructor
new TCPConnection(connID, transport, driverFactory)
Parameters:
Name | Type | Description |
---|---|---|
connID |
number | Unique identifier of the connection this dispatcher should handle. |
transport |
DebuggerTransport | Debugger transport connection to the client. |
driverFactory |
function | Factory function that produces a |GeckoDriver|. |
Methods
createResponse(msgID) → {message.Response}
Fail-safe creation of a new instance of |message.Response|.
Parameters:
Name | Type | Description |
---|---|---|
msgID |
number | Message ID to respond to. If it is not a number, -1 is used. |
Returns:
Response to the message with |msgID|.
- Type
- message.Response
execute(cmd)
Executes a WebDriver command and sends back a response when it has finished executing.
Commands implemented in GeckoDriver and registered in its {@code GeckoDriver.commands} attribute. The return values from commands are expected to be Promises. If the resolved value of said promise is not an object, the response body will be wrapped in an object under a "value" field.
If the command implementation sends the response itself by calling {@code resp.send()}, the response is guaranteed to not be sent twice.
Errors thrown in commands are marshaled and sent back, and if they are not WebDriverError instances, they are additionally propagated and reported to {@code Components.utils.reportError}.
Parameters:
Name | Type | Description |
---|---|---|
cmd |
Command | The requested command to execute. |
onClosed()
Debugger transport callback that cleans up after a connection is closed.
onPacket(data)
Callback that receives data packets from the client.
If the message is a Response, we look up the command previously issued to the client and run its callback, if any. In case of a Command, the corresponding is executed.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array.<number, number, ?, ?> | A four element array where the elements, in sequence, signifies message type, message ID, method name or error, and parameters or result. |
sayHello()
When a client connects we send across a JSON Object defining the protocol level.
This is the only message sent by Marionette that does not follow the regular message format.
send(msg)
Delegates message to client based on the provided {@code cmdID}. The message is sent over the debugger transport socket.
The command ID is a unique identifier assigned to the client's request that is used to distinguish the asynchronous responses.
Whilst responses to commands are synchronous and must be sent in the correct order.
Parameters:
Name | Type | Description |
---|---|---|
msg |
Message | The command or response to send. |
sendMessage(msg)
Marshal message to the Marionette message format and send it.
Parameters:
Name | Type | Description |
---|---|---|
msg |
Message | The message to send. |
sendRaw(payload)
Send the given payload over the debugger transport socket to the connected client.
Parameters:
Name | Type | Description |
---|---|---|
payload |
Object.<string, ?> | The payload to ship. |
sendToClient(resp)
Send given response to the client over the debugger transport socket.
Parameters:
Name | Type | Description |
---|---|---|
resp |
Response | The response to send back to the client. |