Connection
One accepted websocket, on the gateway or the voice gateway: where it was dialled, which session it is bound to, and every message the client sent on it.
Summary
Properties
Connection.index :: numberConnection.sessionId :: string?Connection.path :: stringConnection.socket :: HttpWebSocketConnection.open :: booleanConnection.closeCode :: number?Connection.received :: { Received }Properties
Section titled “Properties”The connection's place in its server's open order, from 1.
sessionId
Section titled “sessionId”The session the server bound this connection to by answering it with READY or RESUMED, or the voice Ready or Resumed.
The upgrade path with one trailing / removed: a resume dial records /resume, a fresh dial /.
socket
Section titled “socket”The Zune server socket.
False once the server's close callback has run for this connection.
closeCode
Section titled “closeCode”The code the server's close callback reported, nil while open.
received
Section titled “received”Every message the client sent: its opcode, the decoded payload, the raw text or binary buffer, and the world clock's time it arrived.
Methods
Section titled “Methods”sendRaw
Section titled “sendRaw”Connection : sendRaw ( message ) -> boolean
Sends one message as it is, a string as a text frame and a buffer as a binary frame, and returns whether it went.
Zune throws once the socket is closing, before the server's close callback clears open, so a send to a closing
socket returns false.
Parameters
| message: string | buffer |
Returns
| boolean |
Connection : send ( payload ) -> boolean
Sends one payload as JSON text and returns whether it went, as sendRaw does.
Parameters
| payload: Payload |
Returns
| boolean |
Connection : close ( code ) -> ()
Closes the connection with code (1000 by default). Closing a socket that is already closing does nothing.
Parameters
| code: number? |
receivedOps
Section titled “receivedOps”Connection : receivedOps ( opcode ) -> { Received }
Returns the records of every received payload with opcode, oldest first.
Parameters
| opcode: number |
Returns
| { Received } |
Functions
Section titled “Functions”Connection . find ( connections , socket ) -> Connection?
Returns the connection in connections that wraps socket, nil when none does.
Parameters
| connections: { Connection } | |
| socket: ZuneSocket |
Returns
| Connection? |
Connection . new ( settings ) -> Connection
Wraps a server socket the moment it opens.
Parameters
| settings: { index: number, path: string, socket: ZuneSocket, } |
Returns
| Connection |