Attempts to combine the reliability of TCP, specifically full-duplex two-way communication, automatic retransmission of dropped packets, and in-order packet arrival, with the lower-latency benefits of UDP. A SCLOrkWire wraps arbitrary OSC messages in its own protocol, allows for sending of those messages using sendMsg similar to a NetAddr, and also provides a means to respond to incoming OSC messages using the onMessageReceived function callback.
Makes a new SCLOrkWire using the provided arguments.
receivePort |
The port on this computer that the SCLOrkWire should listen on. NOTE: SCLOrkWires are designed to uniquely own a specific port. While other OSC messages can be received on that port multiple SCLOrkWires listening on the same port may create problems if the remote machines have the same id. |
id |
A unique identifier that will be supplied to the remote machine, that the remote machine will use in all subsequent communications to this client. |
timeout |
The amount of time, in seconds, that the SCLOrkWire should wait before attempting retransmission of any data. |
maxRetries |
The number of times that the wire should try retransmitting data before giving up with a failure state. |
bufferSize |
The size of internal buffers for sending and receiving. The buffers are primarily used for re-ordering of packets that arrive out-of-order, so the size of the buffer conceptually represents the maximum number of packets that the system can tolerate receiving out-of-order before receving retransmission of the in-order data. |
netAddrFactory |
Useful for testing, allows the user to provide a function that when called with hostname, port arguments will return a NetAddr or similar mocked object. For production code leave at default value. |
A shiny new SCLOrkWire.
Will start listening to knock requests on the provided port, calling onKnock function with every new wire made.
port |
The port to listen to. Will not re-open or re-assign ports for which bind has already been called. |
wireIssueId |
A function that will be evaulated to issue unique identifiers to the wire clients. This value will become the id in the created wires. |
wireOnConnected |
A function that bind provides to the constructed SCLOrkWire objects as their onConnected function. |
wireOnMessageReceived |
A function that bind provides to the constructed SCLOrkWire objects as their onMessageReceived function. |
onKnock |
A function that the SCLOrkWire will call on the initiation of each client connection. The function is called with a sole argument which is the newly created wire object. |
netAddrFactory |
Used for testing, will provide this netAddrFactory function to the SCLOrkWire objects created by bind. Production code should leave at default. |
Removes any binding function listening at port. Note than any existing SCLOrkWire connections are unaffected by this operation.
port |
The port number to stop listening on. |
Initiate the process to normally terminate the connection, resulting in an eventual connection state change to \disconnected or \failureTimeout.
Accessor for the unique identifier number provided by the remote connection.
Accessor for the unique identifier provided by the client code on this side at construction time.
Returns the current connection state of the SCLOrkWire, a label enum. The following values are in use:
label value | discussion |
\neverConnected | The initial state of a SCLOrkWire, before any connection attempted or requested. |
\knocking | The wire is communicating with the remote to get a port assigned, valid next states are either \connectionRequested or \failureTimeout. |
\failureTimeout | Some communication the server has timed out and exceeded maximum retries. This is a terminal state of the wire. |
\disconnected | Normal disconnection procedure has completed. This is a terminal state of the wire. |
\connected | The wire is connected. Valid next states are \disconnected, \disconnectRequested, or \failureTimeout. |
\connectionRequested | The wire is responding to an incoming connection request. Valid next states are \connected or \failureTimeout. |
\connectionAccepted | The wire is attempting to initiate a connection to the remote host. Valid next states are \connected or \failureTimeout. |
\disconnectRequested | The wire is attempting to disconnect from the remote host. Valid next states are \disconnected or \failureTimeout. |
The function this SCLOrkWire will call on receipt of a message from the remote host. The function is called with arguments wire, messageArray, where wire is the wire receiving the message, and messageArray is the OSC message that was sent, provided in a manner identical to that of OSCFunc message argument.
Send the provided arguments as an OSC message to the remote host. Arguments are provided in a manner identical to that of NetAddr: sendMsg.
... args |
The message to send. |
If connected, disconnect the wire, then delete the object and unbind all listening for messages.
Attempt to contact hostname at hostPort requesting that they assign a port and initiate a connection with us at our receivePort provided at constrution time.
hostname |
The name or ip address of the remote host to contact. |
knockPort |
The port that the remote host has bound with bind. |
Will be true if the wire is \connected or \disconnected and is not currently sending data or has buffered out-of-order received data. Useful for testing.
A function called when there's a change in connectionState. The function is called with arguments wire, state, where wire is the wire reporting the state change and state is any of the enum values detailed in the connectionState table.
Initiate a connection to the remote host.
hostname |
The name or ip address of the remote host to connect to. |
requestPort |
The port on the remote host to initiate connection with. |