Class WebSocketConnection
A WebSocket byte stream: each message in is a run of bytes for the terminal, and each run of bytes out is one binary message. It runs in a WebGL player, where DarkEffekt.Terminal.TcpConnection cannot, and suits a relay in front of a pty or a serial port. Connect returns at once; a connect that fails arrives through Closed, and bytes sent before the connect completes go out once it does.
Assembly: DarkEffekt.Terminal.Core
Section titled “Assembly: DarkEffekt.Terminal.Core”public class WebSocketConnection : ITerminalConnectionDerived:
DarkEffekt.Terminal.TtydConnection
Implements:
DarkEffekt.Terminal.ITerminalConnection
Properties
Section titled “Properties”The address, starting with ws:// or wss://.
public string Url { get; }Subprotocols
Section titled “Subprotocols”The subprotocols to offer the server, in order of preference. Set before Connect.
public IReadOnlyList<string> Subprotocols { get; set; }IsConnected
Section titled “IsConnected”public bool IsConnected { get; }Methods
Section titled “Methods”Connect()
Section titled “Connect()”Starts connecting and returns at once; Connected or Closed reports the outcome.
public void Connect()OnConnected()
Section titled “OnConnected()”The socket is open. Runs before anything queued goes out and before Connected, so a message sent from here with SendRaw is the first the server reads.
protected virtual void OnConnected()HandleMessage(byte[])
Section titled “HandleMessage(byte[])”Processes one message from the server. The base class raises DataReceived with it.
protected virtual void HandleMessage(byte[] data)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.Byte[] |
data |
RaiseDataReceived(byte[])
Section titled “RaiseDataReceived(byte[])”protected void RaiseDataReceived(byte[] data)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.Byte[] |
data |
Send(byte[], int, int)
Section titled “Send(byte[], int, int)”Queues bytes for the far end. Never blocks on the network.
public virtual void Send(byte[] data, int offset, int count)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.Byte[] |
data |
System.Int32 |
offset |
System.Int32 |
count |
SendRaw(byte[])
Section titled “SendRaw(byte[])”Queues one message for the server as it is. The array must not change afterward.
protected void SendRaw(byte[] data)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.Byte[] |
data |
NotifyResize(int, int)
Section titled “NotifyResize(int, int)”The terminal grid changed size. Connections that can pass this on do.
public virtual void NotifyResize(int cols, int rows)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.Int32 |
cols |
System.Int32 |
rows |
Dispose()
Section titled “Dispose()”Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()Events
Section titled “Events”Connected
Section titled “Connected”The stream is open and data can flow.
public event Action ConnectedEvent Type
Section titled “Event Type”System.Action
DataReceived
Section titled “DataReceived”public event Action<byte[]> DataReceivedEvent Type
Section titled “Event Type”System.Action<System.Byte[]>
Closed
Section titled “Closed”public event Action<CloseReason> ClosedEvent Type
Section titled “Event Type”System.Action<DarkEffekt.Terminal.CloseReason>