Nakama .NET Client SDK 3.8.0
Nakama .NET Client SDK
Loading...
Searching...
No Matches
Nakama.Ninja.WebSockets.WebSocketClientFactory Class Reference

Web socket client factory used to open web socket client connections. More...

Inheritance diagram for Nakama.Ninja.WebSockets.WebSocketClientFactory:
Nakama.Ninja.WebSockets.IWebSocketClientFactory

Public Member Functions

 WebSocketClientFactory ()
 Initialises a new instance of the WebSocketClientFactory class without caring about internal buffers.
 
 WebSocketClientFactory (Func< MemoryStream > bufferFactory)
 Initialises a new instance of the WebSocketClientFactory class with control over internal buffer creation.
 
async Task< WebSocket > ConnectAsync (Uri uri, CancellationToken token=default(CancellationToken))
 Connect with default options.
 
async Task< WebSocket > ConnectAsync (Uri uri, WebSocketClientOptions options, CancellationToken token=default(CancellationToken))
 Connect with options specified.
 
async Task< WebSocket > ConnectAsync (System.IO.Stream responseStream, string secWebSocketKey, WebSocketClientOptions options, CancellationToken token=default(CancellationToken))
 Connect with a stream that has already been opened and HTTP websocket upgrade request sent This function will check the handshake response from the server and proceed if successful Use this function if you have specific requirements to open a conenction like using special http headers and cookies You will have to build your own HTTP websocket upgrade request You may not even choose to use TCP/IP and this function will allow you to do that.
 

Protected Member Functions

virtual void TlsAuthenticateAsClient (SslStream sslStream, string host)
 Override this if you need more fine grained control over the TLS handshake like setting the SslProtocol or adding a client certificate.
 
virtual async Task< System.IO.Stream > GetStream (Guid loggingGuid, bool isSecure, bool noDelay, string host, int port, CancellationToken cancellationToken)
 Override this if you need more control over how the stream used for the websocket is created. It does not event need to be a TCP stream.
 

Detailed Description

Web socket client factory used to open web socket client connections.

Constructor & Destructor Documentation

◆ WebSocketClientFactory() [1/2]

Nakama.Ninja.WebSockets.WebSocketClientFactory.WebSocketClientFactory ( )
inline

Initialises a new instance of the WebSocketClientFactory class without caring about internal buffers.

◆ WebSocketClientFactory() [2/2]

Nakama.Ninja.WebSockets.WebSocketClientFactory.WebSocketClientFactory ( Func< MemoryStream >  bufferFactory)
inline

Initialises a new instance of the WebSocketClientFactory class with control over internal buffer creation.

Parameters
bufferFactoryUsed to get a memory stream. Feel free to implement your own buffer pool. MemoryStreams will be disposed when no longer needed and can be returned to the pool.

Member Function Documentation

◆ ConnectAsync() [1/3]

async Task< WebSocket > Nakama.Ninja.WebSockets.WebSocketClientFactory.ConnectAsync ( System::IO::Stream  responseStream,
string  secWebSocketKey,
WebSocketClientOptions  options,
CancellationToken  token = default(CancellationToken) 
)
inline

Connect with a stream that has already been opened and HTTP websocket upgrade request sent This function will check the handshake response from the server and proceed if successful Use this function if you have specific requirements to open a conenction like using special http headers and cookies You will have to build your own HTTP websocket upgrade request You may not even choose to use TCP/IP and this function will allow you to do that.

Parameters
responseStreamThe full duplex response stream from the server
secWebSocketKeyThe secWebSocketKey you used in the handshake request
optionsThe WebSocket client options
tokenThe optional cancellation token
Returns

Implements Nakama.Ninja.WebSockets.IWebSocketClientFactory.

◆ ConnectAsync() [2/3]

async Task< WebSocket > Nakama.Ninja.WebSockets.WebSocketClientFactory.ConnectAsync ( Uri  uri,
CancellationToken  token = default(CancellationToken) 
)
inline

Connect with default options.

Parameters
uriThe WebSocket uri to connect to (e.g. ws://example.com or wss://example.com for SSL)
tokenThe optional cancellation token
Returns
A connected web socket instance

Implements Nakama.Ninja.WebSockets.IWebSocketClientFactory.

◆ ConnectAsync() [3/3]

async Task< WebSocket > Nakama.Ninja.WebSockets.WebSocketClientFactory.ConnectAsync ( Uri  uri,
WebSocketClientOptions  options,
CancellationToken  token = default(CancellationToken) 
)
inline

Connect with options specified.

Parameters
uriThe WebSocket uri to connect to (e.g. ws://example.com or wss://example.com for SSL)
optionsThe WebSocket client options
tokenThe optional cancellation token
Returns
A connected web socket instance

Implements Nakama.Ninja.WebSockets.IWebSocketClientFactory.

◆ GetStream()

virtual async Task< System.IO.Stream > Nakama.Ninja.WebSockets.WebSocketClientFactory.GetStream ( Guid  loggingGuid,
bool  isSecure,
bool  noDelay,
string  host,
int  port,
CancellationToken  cancellationToken 
)
inlineprotectedvirtual

Override this if you need more control over how the stream used for the websocket is created. It does not event need to be a TCP stream.

Parameters
loggingGuidFor logging purposes only
isSecureMake a secure connection
noDelaySet to true to send a message immediately with the least amount of latency (typical usage for chat)
hostThe destination host (can be an IP address)
portThe destination port
cancellationTokenUsed to cancel the request
Returns
A connected and open stream

◆ TlsAuthenticateAsClient()

virtual void Nakama.Ninja.WebSockets.WebSocketClientFactory.TlsAuthenticateAsClient ( SslStream  sslStream,
string  host 
)
inlineprotectedvirtual

Override this if you need more fine grained control over the TLS handshake like setting the SslProtocol or adding a client certificate.


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