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

Static Public Member Functions

static string CalculateWebSocketKey ()
 Calculates a random WebSocket key that can be used to initiate a WebSocket handshake.
 
static string ComputeSocketAcceptString (string secWebSocketKey)
 Computes a WebSocket accept string from a given key.
 
static async Task< string > ReadHttpHeaderAsync (System.IO.Stream stream, CancellationToken token)
 Reads an http header as per the HTTP spec.
 
static bool IsWebSocketUpgradeRequest (String header)
 Decodes the header to detect is this is a web socket upgrade response.
 
static string GetPathFromHeader (string httpHeader)
 Gets the path from the HTTP header.
 
static IList< string > GetSubProtocols (string httpHeader)
 
static string ReadHttpResponseCode (string response)
 Reads the HTTP response code from the http response string.
 
static async Task WriteHttpHeaderAsync (string response, System.IO.Stream stream, CancellationToken token)
 Writes an HTTP response string to the stream.
 

Member Function Documentation

◆ CalculateWebSocketKey()

static string Nakama.Ninja.WebSockets.HttpHelper.CalculateWebSocketKey ( )
inlinestatic

Calculates a random WebSocket key that can be used to initiate a WebSocket handshake.

Returns
A random websocket key

◆ ComputeSocketAcceptString()

static string Nakama.Ninja.WebSockets.HttpHelper.ComputeSocketAcceptString ( string  secWebSocketKey)
inlinestatic

Computes a WebSocket accept string from a given key.

Parameters
secWebSocketKeyThe web socket key to base the accept string on
Returns
A web socket accept string

◆ GetPathFromHeader()

static string Nakama.Ninja.WebSockets.HttpHelper.GetPathFromHeader ( string  httpHeader)
inlinestatic

Gets the path from the HTTP header.

Parameters
httpHeaderThe HTTP header to read
Returns
The path

◆ GetSubProtocols()

static IList< string > Nakama.Ninja.WebSockets.HttpHelper.GetSubProtocols ( string  httpHeader)
inlinestatic

◆ IsWebSocketUpgradeRequest()

static bool Nakama.Ninja.WebSockets.HttpHelper.IsWebSocketUpgradeRequest ( String  header)
inlinestatic

Decodes the header to detect is this is a web socket upgrade response.

Parameters
headerThe HTTP header
Returns
True if this is an http WebSocket upgrade response

◆ ReadHttpHeaderAsync()

static async Task< string > Nakama.Ninja.WebSockets.HttpHelper.ReadHttpHeaderAsync ( System::IO::Stream  stream,
CancellationToken  token 
)
inlinestatic

Reads an http header as per the HTTP spec.

Parameters
streamThe stream to read UTF8 text from
tokenThe cancellation token
Returns
The HTTP header

◆ ReadHttpResponseCode()

static string Nakama.Ninja.WebSockets.HttpHelper.ReadHttpResponseCode ( string  response)
inlinestatic

Reads the HTTP response code from the http response string.

Parameters
responseThe response string
Returns
the response code

◆ WriteHttpHeaderAsync()

static async Task Nakama.Ninja.WebSockets.HttpHelper.WriteHttpHeaderAsync ( string  response,
System::IO::Stream  stream,
CancellationToken  token 
)
inlinestatic

Writes an HTTP response string to the stream.

Parameters
responseThe response (without the new line characters)
streamThe stream to write to
tokenThe cancellation token

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