YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.sendspin.session.SecureChannel Class Reference

The encrypted channel after the handshake: every WebSocket binary message is one Noise transport message whose plaintext is a message id byte followed by the body (id 0: a JSON message, 1: a fragment of a larger message, 4 to 7: player audio ...). More...

Collaboration diagram for de.yaacc.sendspin.session.SecureChannel:
Collaboration graph

Classes

class  Inbound
 A message after decryption (and reassembly): its id and its body.
 

Public Member Functions

 SecureChannel (WsConnection ws, NoiseTransport transport)
 
boolean isPlain ()
 True for the plain channel of the older wire.
 
NoiseTransport transport ()
 
void sendJson (String json) throws IOException
 Sends a JSON message (id 0).
 
void sendMessage (int id, byte[] body) throws IOException
 Sends a binary message of the given id.
 
Inbound receive () throws IOException, ProtocolException, NoiseException
 Blocks for the next message.
 
void close (int code)
 Sends a close frame; the caller closes the socket.
 

Static Public Member Functions

static SecureChannel plain (WsConnection ws)
 The channel of the older, unencrypted wire (the "transition mode", only when the user allows it): a JSON message is a WebSocket text message, anything else a binary message that starts with its id byte.
 

Static Public Attributes

static final int MAX_BODY = NoiseTransport.MAX_PLAINTEXT_LENGTH - 1
 The room of one transport message: the plaintext holds the id byte and the body.
 

Detailed Description

The encrypted channel after the handshake: every WebSocket binary message is one Noise transport message whose plaintext is a message id byte followed by the body (id 0: a JSON message, 1: a fragment of a larger message, 4 to 7: player audio ...).

Sending is serialized: encrypting and writing happen under one lock, so the counters run in the order of the frames on the wire. Reading is for one thread. A text message, a message that does not verify, an empty one and every malformed fragment sequence end the connection (the caller closes).

Member Function Documentation

◆ plain()

static SecureChannel de.yaacc.sendspin.session.SecureChannel.plain ( WsConnection ws)
static

The channel of the older, unencrypted wire (the "transition mode", only when the user allows it): a JSON message is a WebSocket text message, anything else a binary message that starts with its id byte.

There is no transport and nothing is encrypted.

Referenced by de.yaacc.sendspin.session.SecureChannel.receive(), and de.yaacc.sendspin.session.SecureChannel.sendMessage().

Here is the caller graph for this function:

◆ receive()

Inbound de.yaacc.sendspin.session.SecureChannel.receive ( ) throws IOException, ProtocolException, NoiseException

Blocks for the next message.

Exceptions
java.net.SocketTimeoutExceptionif nothing arrived (the connection is intact)
ProtocolExceptionif the peer broke a rule of the protocol (close)
NoiseExceptionif a message does not verify (close without a message)
Here is the call graph for this function:

◆ sendMessage()

void de.yaacc.sendspin.session.SecureChannel.sendMessage ( int id,
byte[] body ) throws IOException

Sends a binary message of the given id.

Parameters
bodyat most MAX_BODY bytes (larger messages are not sent by this server role yet)

Referenced by de.yaacc.sendspin.session.SecureChannel.sendJson().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: