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 |
Methods
createResponse(msgID) → {Response}
Fail-safe creation of a new instance of 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
- Response
(async) despatch(cmd, resp)
Despatches command to appropriate Marionette service.
Parameters:
Name | Type | Description |
---|---|---|
cmd |
Command | Command to run. |
resp |
Response | Mutable response where the command's return value will be assigned. |
Throws:
-
A command's implementation may throw at any time.
- Type
- Error
(async) execute(cmd)
Executes a Marionette command and sends back a response when it has finished executing.
If the command implementation sends the response itself by calling
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 Components.utils.reportError
.
Parameters:
Name | Type | Description |
---|---|---|
cmd |
Command | 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. |