Class TcpConnection
A raw TCP byte stream, for a service that speaks plain lines, such as a MUD or a server of your own, and the base class for the telnet connection. Connect returns at once: the name lookup, the connect, the reads, and the writes all run on background threads. 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 TcpConnection : ITerminalConnectionDerived:
DarkEffekt.Terminal.TelnetConnection
Implements:
DarkEffekt.Terminal.ITerminalConnection
Properties
Section titled “Properties”IsSupported
Section titled “IsSupported”Whether this platform has sockets. False in a WebGL player, where DarkEffekt.Terminal.WebSocketConnection reaches a host and this cannot.
public static bool IsSupported { get; }public string Host { get; }public int Port { get; }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 stream is open. Runs on the background thread, before the first read and before Connected.
protected virtual void OnConnected()HandleIncoming(byte[], int)
Section titled “HandleIncoming(byte[], int)”Processes n bytes read from the wire. The base class raises DataReceived directly.
protected virtual void HandleIncoming(byte[] buffer, int n)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.Byte[] |
buffer |
System.Int32 |
n |
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 bytes for the wire as they are. 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>