Socket implementation for TCPTransport. TCP Transport delegates to an instance of this class. This is used internally by the client's transport. There is usually no reason to make direct use of it. Its functionality is best accessed via the client instance.
More...
|
readonly object | _lock = new object() |
|
volatile int | _connectionVersion = 0 |
|
|
void | broadcastException (Exception e) |
| Broadcasts an exception to the exception listener if available. More...
|
|
virtual IPAddress | resolveAddress (Uri addr) |
| Resolves the IP address for the provided URI. More...
|
|
virtual void | createSocket () |
| Creates a socket based on the resolved address. More...
|
|
virtual void | createStream (Uri uri) |
| Creates a stream for the provided URI and connects the socket. More...
|
|
virtual void | connectSocket (Uri addr) |
| Connects the socket to the specified URI. More...
|
|
void | handshake () |
| Initiates the handshake process for the transport. More...
|
|
virtual void | applySocketProperty (String propertyName, String propertyValue) |
| Applies a socket property to self. Override this to add custom properties to your transport or intercept the stock ones. More...
|
|
|
Client | _client = null |
|
Uri | _addr |
|
IPAddress | _resolvedAddr |
|
Stream | _socketStream = null |
|
Socket | _socket = null |
|
bool | _httpPreflight = false |
|
bool | _handshakeSetStream = false |
|
Socket implementation for TCPTransport. TCP Transport delegates to an instance of this class. This is used internally by the client's transport. There is usually no reason to make direct use of it. Its functionality is best accessed via the client instance.
◆ TCPTransportImpl()
AMPS.Client.TCPTransportImpl.TCPTransportImpl |
( |
Protocol |
messageType_, |
|
|
Properties |
properties_ |
|
) |
| |
|
inline |
Initializes a new instance of the TCPTransportImpl class with the specified message type and properties.
- Parameters
-
messageType_ | The message type for the transport. |
properties_ | The properties for configuring the transport. |
◆ applySocketProperty()
virtual void AMPS.Client.TCPTransportImpl.applySocketProperty |
( |
String |
propertyName, |
|
|
String |
propertyValue |
|
) |
| |
|
inlineprotectedvirtual |
Applies a socket property to self. Override this to add custom properties to your transport or intercept the stock ones.
- Parameters
-
propertyName | The property name from the URI. |
propertyValue | The property value. |
◆ broadcastException()
void AMPS.Client.TCPTransportImpl.broadcastException |
( |
Exception |
e | ) |
|
|
inlineprotected |
Broadcasts an exception to the exception listener if available.
- Parameters
-
e | The exception to broadcast. |
◆ connect()
void AMPS.Client.TCPTransportImpl.connect |
( |
Uri |
addr | ) |
|
|
inline |
Establishes a connection to the specified address.
- Parameters
-
addr | The address to connect to. |
- Exceptions
-
AlreadyConnectedException | |
InvalidURIException | |
ConnectionRefusedException | |
◆ connectSocket()
virtual void AMPS.Client.TCPTransportImpl.connectSocket |
( |
Uri |
addr | ) |
|
|
inlineprotectedvirtual |
Connects the socket to the specified URI.
- Parameters
-
addr | The URI to connect to. |
- Exceptions
-
SocketException | Thrown when an error occurs while connecting the socket. |
◆ createSocket()
virtual void AMPS.Client.TCPTransportImpl.createSocket |
( |
| ) |
|
|
inlineprotectedvirtual |
Creates a socket based on the resolved address.
◆ createStream()
virtual void AMPS.Client.TCPTransportImpl.createStream |
( |
Uri |
uri | ) |
|
|
inlineprotectedvirtual |
Creates a stream for the provided URI and connects the socket.
- Parameters
-
uri | The URI to create the stream for. |
Reimplemented in AMPS.Client.TCPSTransportImpl.
◆ createTransport()
Creates a new TCP transport based on the provided protocol and implementation.
- Parameters
-
messageType | The protocol for the transport. |
impl | The implementation of the TCP transport. |
- Returns
- A new TCP transport instance.
◆ disconnect()
void AMPS.Client.TCPTransportImpl.disconnect |
( |
| ) |
|
|
inline |
Disconnects the TCP transport.
◆ flush() [1/2]
long AMPS.Client.TCPTransportImpl.flush |
( |
| ) |
|
|
inline |
Flushes any pending data in the TCP transport.
- Returns
- Always returns 0.
◆ flush() [2/2]
long AMPS.Client.TCPTransportImpl.flush |
( |
long |
timeout | ) |
|
|
inline |
Flushes any pending data in the TCP transport with a specified timeout.
- Parameters
-
timeout | The timeout period. |
- Returns
- Always returns 0.
◆ getIdleAction()
Action AMPS.Client.TCPTransportImpl.getIdleAction |
( |
| ) |
|
|
inline |
Gets the idle action for the TCP transport.
- Returns
- The action to be performed during idle periods.
◆ handleCloseEvent()
virtual void AMPS.Client.TCPTransportImpl.handleCloseEvent |
( |
int |
failedVersion_, |
|
|
String |
message, |
|
|
Exception |
exception |
|
) |
| |
|
inlinevirtual |
Handles a close event, such as a disconnection or error, by invoking the appropriate disconnect handler.
- Parameters
-
failedVersion_ | The version of the failed connection. |
message | The error message. |
exception | The exception that caused the disconnection. |
- Exceptions
-
DisconnectedException | Thrown when a disconnect occurs. |
RetryOperationException | Thrown when a reconnect is attempted. |
◆ handshake()
void AMPS.Client.TCPTransportImpl.handshake |
( |
| ) |
|
|
inlineprotected |
Initiates the handshake process for the transport.
◆ initFromClient()
void AMPS.Client.TCPTransportImpl.initFromClient |
( |
Client |
client | ) |
|
|
inline |
Initializes the transport configuration from the provided client.
- Parameters
-
client | The client from which to initialize the transport configuration. |
◆ readQueueSize()
long AMPS.Client.TCPTransportImpl.readQueueSize |
( |
| ) |
|
|
inline |
Returns the size of the read queue.
- Returns
- The size of the read queue.
◆ resolveAddress()
virtual IPAddress AMPS.Client.TCPTransportImpl.resolveAddress |
( |
Uri |
addr | ) |
|
|
inlineprotectedvirtual |
Resolves the IP address for the provided URI.
- Parameters
-
- Returns
- The resolved IP address.
- Exceptions
-
InvalidURIException | Thrown when the URI hostname cannot be resolved. |
◆ send()
void AMPS.Client.TCPTransportImpl.send |
( |
MemoryStream |
buf | ) |
|
|
inline |
Sends the data contained in the provided memory stream over the socket.
- Parameters
-
buf | The memory stream containing the data to send. |
- Exceptions
-
DisconnectedException | Thrown when the socket is closed or encounters an error while sending the message. |
◆ setDisconnectHandler()
Sets the disconnect handler for the TCP transport.
- Parameters
-
h | The disconnect handler to set. |
◆ setExceptionListener()
void AMPS.Client.TCPTransportImpl.setExceptionListener |
( |
ExceptionListener |
e | ) |
|
|
inline |
Sets the exception listener for the TCP transport.
- Parameters
-
e | The exception listener to set. |
◆ setIdleAction()
void AMPS.Client.TCPTransportImpl.setIdleAction |
( |
Action |
idleAction | ) |
|
|
inline |
Sets the idle action for the TCP transport.
- Parameters
-
idleAction | The idle action to set. |
◆ setMessageHandler()
void AMPS.Client.TCPTransportImpl.setMessageHandler |
( |
MessageHandler |
h | ) |
|
|
inline |
Sets the message handler for the TCP transport.
- Parameters
-
h | The message handler to set. |
◆ setReadTimeout()
void AMPS.Client.TCPTransportImpl.setReadTimeout |
( |
int |
readTimeoutMillis_ | ) |
|
|
inline |
Sets the read timeout for the TCP transport.
- Parameters
-
readTimeoutMillis_ | The read timeout in milliseconds. |
◆ setThreadCreatedHandler()
Sets the thread created handler for the TCP transport.
- Parameters
-
handler | The thread created handler to set. |
◆ setTransportFilter()
Sets the transport filter for the TCP transport.
- Parameters
-
filter_ | The transport filter to set. |
◆ socket()
Socket AMPS.Client.TCPTransportImpl.socket |
( |
| ) |
|
|
inline |
Returns the socket associated with this TCP transport.
- Returns
- The socket associated with this TCP transport.
◆ writeQueueSize()
long AMPS.Client.TCPTransportImpl.writeQueueSize |
( |
| ) |
|
|
inline |
Returns the size of the write queue.
- Returns
- The size of the write queue.
The documentation for this class was generated from the following file:
- AMPS.Client/TCPTransportImpl.cs