• MARS Website
  • Core API
  • SmartOpenHamburg API
  • Model Components API
  • Common API
Show / Hide Table of Contents
  • Mars.Common
    • GeoHash
    • GeoHashDecoder
    • GeohashDecodeResult
    • GeoHashEncoder
    • GeoHashPrecision
    • Hyperrectangle
    • InputHashHelper
    • PositionHelper
  • Mars.Common.Collections
    • BinaryArrayHeap<T>
    • DoubleBits
    • FibonacciHeap<T, TKey>
    • FibonacciHeapDoubleKey<T>
    • FibonacciHeapNode<T, TKey>
    • FibonacciHeapNodeDoubleKey<T>
    • HeapNode
    • IntervalSize
    • K2DTree<T>
    • K2dTreeNode<T>
    • KdTree
    • KdTree<T>
    • KdTreeBase<TNode>
    • KdTreeNode
    • KdTreeNode<T>
    • KdTreeNodeBase<TNode>
    • KdTreeNodeCollection<TNode>
    • KdTreeNodeList<T>
    • Key
    • Node<T>
    • NodeBase<T>
    • NodeDataContainer<T>
    • NodeDistance<TNode>
    • QuadTree<T>
    • Root<T>
    • TreeDataContainer<T>
  • Mars.Common.Collections.CritBit
    • ICritBitTree<TValue>
  • Mars.Common.Collections.Graph
    • EdgeData
    • GraphData
    • GraphSerializer
    • ISpatialGraph
    • KeyContainer
    • NodeData
    • SpatialGraph
    • SpatialGraphHelper
  • Mars.Common.Collections.Graph.Algorithms
    • AStar
    • CompressedPathDatabase
    • ContractionSearch
    • DepthLimitedTraversal
  • Mars.Common.Collections.Graph.Helper
    • INodeFinder
    • KdTreeNodeFinder
    • RunLengthEncoder
  • Mars.Common.Collections.KNNGraph
    • DefaultRandomGenerator
    • DistanceUtils
    • EventSources
    • EventSources.GraphBuildEventSource
    • EventSources.GraphSearchEventSource
    • IProgressReporter
    • IProvideRandomValues
    • KnnGraph<TItem, TDistance>
    • KnnGraph<TItem, TDistance>.KnnSearchResult
    • KnnGraph<TItem, TDistance>.Parameters
    • Node
    • ReverseComparer<T>
    • ReverseComparerExtensions
    • SelectionKind
    • TravelingCosts<TItem, TDistance>
  • Mars.Common.Compat
    • FormatDecoderAttribute
    • FormatEncoderAttribute
    • FormatHandlerAttribute
    • IntegerAttribute
    • NegativeIntegerAttribute
    • NonnegativeIntegerAttribute
    • NonpositiveIntegerAttribute
    • PositiveIntegerAttribute
  • Mars.Common.Data
    • DomainDataImporter
  • Mars.Common.Data.Providers
    • AscDataProvider
    • GeoJsonFeatureCollectionConverter
    • GeoJsonFeatureConverter
    • GeoJsonHelper
    • GeometryDataProvider
    • GraphMlProvider
    • HttpDataProvider
    • IDataProvider<TInput>
    • JsonFileDataProvider
    • JsonTextDataProvider
    • XmlFileDataProvider
    • XmlTextDataProvider
  • Mars.Common.Exceptions
    • DimensionMismatchException
    • ParseException
  • Mars.Common.IO
    • ExtensionMethods
    • FileClientUtils
    • FileKeys
    • HttpClientUtils
    • ObjectSerialize
    • Serializer
    • SerializerCompression
    • SparseFormat
    • SparseReader
    • SparseWriter
  • Mars.Common.IO.Attributes
    • SerializationBinderAttribute
    • SurrogateSelectorAttribute
  • Mars.Common.IO.Console
    • ChildProgressBar
    • IProgressBar
    • ProgressBar
    • ProgressBarBase
    • ProgressBarHeight
    • ProgressBarOptions
    • ProgressBarSimple
  • Mars.Common.IO.Csv
    • CsvAnalyzer
    • CsvReader
    • CsvReader.RecordEnumerator
    • CsvWriter
    • MissingFieldAction
    • ParseErrorAction
    • ValueTrimmingOptions
  • Mars.Common.IO.Events
    • ParseErrorEventArgs
  • Mars.Common.IO.Exceptions
    • MalformedCsvException
    • MissingFieldCsvException
  • Mars.Common.IO.Mapped
    • Context
    • DefaultArrayFactory
    • Extensions
    • IArrayFactory
    • ISerializableToStream
    • MappedAccessor<T>
    • MemoryMap
    • MemoryMap.CreateAccessorFunc<T>
    • MemoryMap.ReadFromDelegate<T>
    • MemoryMap.WriteToDelegate<T>
    • MemoryMapDelegates
    • MemoryMapDelegates.CreateAccessorFunc<T>
    • MemoryMapStream
  • Mars.Common.IO.Mapped.Accessors
    • MappedAccessorByte
    • MappedAccessorDouble
    • MappedAccessorInt16
    • MappedAccessorInt32
    • MappedAccessorInt64
    • MappedAccessorSingle
    • MappedAccessorUInt16
    • MappedAccessorUInt32
    • MappedAccessorUInt64
    • MappedAccessorVariable<T>
  • Mars.Common.IO.Mapped.Arrays
    • Array<T>
    • ArrayBase<T>
    • ArrayProfile
    • MappedArray<TMapped, T>
    • MappedArray<TMapped, T>.MapFrom
    • MappedArray<TMapped, T>.MapTo
    • MemoryArray<T>
    • VariableArray<T>
  • Mars.Common.IO.Mapped.Collections
    • MemoryBackedDictionary<TKey, TValue>
    • MemoryBackedList<T>
  • Mars.Common.IO.Mapped.Indexes
    • Index<T>
  • Mars.Common.IO.Mapped.Streams
    • CappedStream
  • Mars.Common.Socket
    • ByteOrder
    • CloseEventArgs
    • CloseStatusCode
    • CompressionMethod
    • ErrorEventArgs
    • Ext
    • MessageEventArgs
    • WebSocket
    • WebSocketException
    • WebSocketState
  • Mars.Common.Socket.Server
    • IWebSocketSession
    • WebHeaderCollection
    • WebSocketBehavior
    • WebSocketContext
    • WebSocketServer
    • WebSocketServiceHost
    • WebSocketServiceManager
    • WebSocketSessionManager
  • Mars.Numerics
    • Classes
    • Combinatorics
    • Constants
    • Distance
    • Elementwise
    • Jagged
    • MathematicsException
    • MathHelper
    • Matrix
    • MatrixOrder
    • MatrixType
    • Norm
    • Sort
    • Sorting
    • Sparse
    • Sparse<T>
    • Tools
    • Vector
    • VectorHelper
    • VectorType
  • Mars.Numerics.Comparers
    • ArrayComparer<T>
    • ComparerDirection
    • CustomComparer<T>
    • ElementComparer
    • ElementComparer<T>
    • GeneralComparer
    • StableComparer<T>
  • Mars.Numerics.Distances
    • Angular
    • Chebyshev
    • Cosine
    • Dirac<T>
    • Euclidean
    • Hamming
    • Hamming<T>
    • Haversine
    • Jaccard
    • Jaccard<T>
    • Kulczynski
    • Levenshtein
    • Levenshtein<T>
    • Manhattan
    • Matching
    • Minkowski
    • SquareEuclidean
    • Vincenty
    • Vincenty.Ellipsoid
  • Mars.Numerics.Distances.Base
    • IDistance<T>
    • IDistance<TFirst, TSecond>
    • IMetric<T>
    • ISimilarity<T, TU>
    • ISimilarity<T>
  • Mars.Numerics.Exceptions
    • DimensionMismatchException
    • NonPositiveDefiniteMatrixException
    • SingularMatrixException
  • Mars.Numerics.Formats
    • DefaultMatrixFormatProvider
    • IMatrixFormatProvider
    • MatrixFormatProviderBase
    • MatrixFormatter
    • OctaveMatrixFormatProvider
  • Mars.Numerics.Ranges
    • ByteRange
    • DoubleRange
    • FloatRange
    • IntRange
    • IRange<T>
  • Mars.Numerics.Statistics
    • ConstValueDistribution<T>
    • Distribution<T>
    • FastGaussianDistributionD
    • FastGaussianDistributionF
    • IDistribution
    • UniformDiscreteDistribution
    • UniformDistributionD
    • UniformDistributionF
  • Mars.Numerics.Statistics.Base
    • BinarySearch
    • DistributionBase
    • ISampleableDistribution<TObservations>
    • IUnivariateDistribution
    • IUnivariateDistribution<TObservation>
    • UnivariateDiscreteDistribution

Class WebSocketSessionManager

Provides the management function for the sessions in a WebSocket service.
Inheritance
System.Object
WebSocketSessionManager
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Common.Socket.Server
Assembly: Mars.Common.dll
Syntax
public class WebSocketSessionManager
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .

Properties

| Improve this Doc View Source

ActiveIDs

Gets the IDs for the active sessions in the WebSocket service.
Declaration
public IEnumerable<string> ActiveIDs { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.String>

An IEnumerable<string> instance.

It provides an enumerator which supports the iteration over the collection of the IDs for the active sessions.

Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
| Improve this Doc View Source

Count

Gets the number of the sessions in the WebSocket service.
Declaration
public int Count { get; }
Property Value
Type Description
System.Int32 An System.Int32 that represents the number of the sessions.
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
| Improve this Doc View Source

IDs

Gets the IDs for the sessions in the WebSocket service.
Declaration
public IEnumerable<string> IDs { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.String>

An IEnumerable<string> instance.

It provides an enumerator which supports the iteration over the collection of the IDs for the sessions.

Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
| Improve this Doc View Source

InactiveIDs

Gets the IDs for the inactive sessions in the WebSocket service.
Declaration
public IEnumerable<string> InactiveIDs { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.String>

An IEnumerable<string> instance.

It provides an enumerator which supports the iteration over the collection of the IDs for the inactive sessions.

Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
| Improve this Doc View Source

Item[String]

Gets the session instance with id.
Declaration
public IWebSocketSession this[string id] { get; }
Parameters
Type Name Description
System.String id A System.String that represents the ID of the session to find.
Property Value
Type Description
IWebSocketSession

A IWebSocketSession instance or null if not found.

The session instance provides the function to access the information in the session.

Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.ArgumentNullException id is null.
System.ArgumentException id is an empty string.
| Improve this Doc View Source

KeepClean

Gets or sets a value indicating whether the inactive sessions in the WebSocket service are cleaned up periodically.
Declaration
public bool KeepClean { get; set; }
Property Value
Type Description
System.Boolean true if the inactive sessions are cleaned up every 60 seconds; otherwise, false.
Remarks
The set operation does nothing if the service has already started or it is shutting down.
| Improve this Doc View Source

Sessions

Gets the session instances in the WebSocket service.
Declaration
public IEnumerable<IWebSocketSession> Sessions { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<IWebSocketSession>

An IEnumerable<IWebSocketSession> instance.

It provides an enumerator which supports the iteration over the collection of the session instances.

Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
| Improve this Doc View Source

WaitTime

Gets or sets the time to wait for the response to the WebSocket Ping or Close.
Declaration
public TimeSpan WaitTime { get; set; }
Property Value
Type Description
System.TimeSpan A System.TimeSpan to wait for the response.
Remarks
The set operation does nothing if the service has already started or it is shutting down.
Exceptions
Type Condition
System.ArgumentOutOfRangeException The value specified for a set operation is zero or less.

Methods

| Improve this Doc View Source

Broadcast(Byte[])

Sends data to every client in the WebSocket service.
Declaration
public void Broadcast(byte[] data)
Parameters
Type Name Description
System.Byte[] data An array of System.Byte that represents the binary data to send.
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.InvalidOperationException The current state of the manager is not Start.
System.ArgumentNullException data is null.
| Improve this Doc View Source

Broadcast(Stream, Int32)

Sends the data from stream to every client in the WebSocket service.
Declaration
public void Broadcast(Stream stream, int length)
Parameters
Type Name Description
System.IO.Stream stream A System.IO.Stream instance from which to read the data to send.
System.Int32 length An System.Int32 that specifies the number of bytes to send.
Remarks
The data is sent as the binary data.
Exceptions
Type Condition
System.InvalidOperationException The current state of the manager is not Start.
System.ArgumentNullException stream is null.
System.ArgumentException

stream cannot be read.

-or-

length is less than 1.

-or-

No data could be read from stream.

| Improve this Doc View Source

Broadcast(String)

Sends data to every client in the WebSocket service.
Declaration
public void Broadcast(string data)
Parameters
Type Name Description
System.String data A System.String that represents the text data to send.
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.InvalidOperationException The current state of the manager is not Start.
System.ArgumentNullException data is null.
System.ArgumentException data could not be UTF-8-encoded.
| Improve this Doc View Source

BroadcastAsync(Byte[], Action)

Sends data asynchronously to every client in the WebSocket service.
Declaration
public void BroadcastAsync(byte[] data, Action completed)
Parameters
Type Name Description
System.Byte[] data An array of System.Byte that represents the binary data to send.
System.Action completed

An System.Action delegate or null if not needed.

The delegate invokes the method called when the send is complete.

Remarks
This method does not wait for the send to be complete.
Exceptions
Type Condition
System.InvalidOperationException The current state of the manager is not Start.
System.ArgumentNullException data is null.
| Improve this Doc View Source

BroadcastAsync(Stream, Int32, Action)

Sends the data from stream asynchronously to every client in the WebSocket service.
Declaration
public void BroadcastAsync(Stream stream, int length, Action completed)
Parameters
Type Name Description
System.IO.Stream stream A System.IO.Stream instance from which to read the data to send.
System.Int32 length An System.Int32 that specifies the number of bytes to send.
System.Action completed

An System.Action delegate or null if not needed.

The delegate invokes the method called when the send is complete.

Remarks

The data is sent as the binary data.

This method does not wait for the send to be complete.

Exceptions
Type Condition
System.InvalidOperationException The current state of the manager is not Start.
System.ArgumentNullException stream is null.
System.ArgumentException

stream cannot be read.

-or-

length is less than 1.

-or-

No data could be read from stream.

| Improve this Doc View Source

BroadcastAsync(String, Action)

Sends data asynchronously to every client in the WebSocket service.
Declaration
public void BroadcastAsync(string data, Action completed)
Parameters
Type Name Description
System.String data A System.String that represents the text data to send.
System.Action completed

An System.Action delegate or null if not needed.

The delegate invokes the method called when the send is complete.

Remarks
This method does not wait for the send to be complete.
Exceptions
Type Condition
System.InvalidOperationException The current state of the manager is not Start.
System.ArgumentNullException data is null.
System.ArgumentException data could not be UTF-8-encoded.
| Improve this Doc View Source

Broadping()

Sends a ping to every client in the WebSocket service.
Declaration
[Obsolete("This method will be removed.")]
public Dictionary<string, bool> Broadping()
Returns
Type Description
System.Collections.Generic.Dictionary<System.String, System.Boolean>

A Dictionary<string, bool>.

It represents a collection of pairs of a session ID and a value indicating whether a pong has been received from the client within a time.

Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.InvalidOperationException The current state of the manager is not Start.
| Improve this Doc View Source

Broadping(String)

Sends a ping with message to every client in the WebSocket service.
Declaration
[Obsolete("This method will be removed.")]
public Dictionary<string, bool> Broadping(string message)
Parameters
Type Name Description
System.String message

A System.String that represents the message to send.

The size must be 125 bytes or less in UTF-8.

Returns
Type Description
System.Collections.Generic.Dictionary<System.String, System.Boolean>

A Dictionary<string, bool>.

It represents a collection of pairs of a session ID and a value indicating whether a pong has been received from the client within a time.

Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.InvalidOperationException The current state of the manager is not Start.
System.ArgumentException message could not be UTF-8-encoded.
System.ArgumentOutOfRangeException The size of message is greater than 125 bytes.
| Improve this Doc View Source

CloseSession(String, CloseStatusCode, String)

Closes the specified session with code and reason.
Declaration
public void CloseSession(string id, CloseStatusCode code, string reason)
Parameters
Type Name Description
System.String id A System.String that represents the ID of the session to close.
CloseStatusCode code

One of the CloseStatusCode enum values.

It represents the status code indicating the reason for the close.

System.String reason

A System.String that represents the reason for the close.

The size must be 123 bytes or less in UTF-8.

Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.ArgumentNullException id is null.
System.ArgumentException

id is an empty string.

-or-

code is MandatoryExtension.

-or-

code is NoStatus and there is reason.

-or-

reason could not be UTF-8-encoded.

System.InvalidOperationException The session could not be found.
System.ArgumentOutOfRangeException The size of reason is greater than 123 bytes.
| Improve this Doc View Source

CloseSession(String, UInt16, String)

Closes the specified session with code and reason.
Declaration
public void CloseSession(string id, ushort code, string reason)
Parameters
Type Name Description
System.String id A System.String that represents the ID of the session to close.
System.UInt16 code

A System.UInt16 that represents the status code indicating the reason for the close.

The status codes are defined in Section 7.4 of RFC 6455.

System.String reason

A System.String that represents the reason for the close.

The size must be 123 bytes or less in UTF-8.

Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.ArgumentNullException id is null.
System.ArgumentException

id is an empty string.

-or-

code is 1010 (mandatory extension).

-or-

code is 1005 (no status) and there is reason.

-or-

reason could not be UTF-8-encoded.

System.InvalidOperationException The session could not be found.
System.ArgumentOutOfRangeException

code is less than 1000 or greater than 4999.

-or-

The size of reason is greater than 123 bytes.

| Improve this Doc View Source

CloseSession(String)

Closes the specified session.
Declaration
public void CloseSession(string id)
Parameters
Type Name Description
System.String id A System.String that represents the ID of the session to close.
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.ArgumentNullException id is null.
System.ArgumentException id is an empty string.
System.InvalidOperationException The session could not be found.
| Improve this Doc View Source

PingTo(String, String)

Sends a ping with message to the client using the specified session.
Declaration
public bool PingTo(string message, string id)
Parameters
Type Name Description
System.String message

A System.String that represents the message to send.

The size must be 125 bytes or less in UTF-8.

System.String id A System.String that represents the ID of the session.
Returns
Type Description
System.Boolean true if the send has done with no error and a pong has been received from the client within a time; otherwise, false.
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.ArgumentNullException id is null.
System.ArgumentException

id is an empty string.

-or-

message could not be UTF-8-encoded.

System.InvalidOperationException The session could not be found.
System.ArgumentOutOfRangeException The size of message is greater than 125 bytes.
| Improve this Doc View Source

PingTo(String)

Sends a ping to the client using the specified session.
Declaration
public bool PingTo(string id)
Parameters
Type Name Description
System.String id A System.String that represents the ID of the session.
Returns
Type Description
System.Boolean true if the send has done with no error and a pong has been received from the client within a time; otherwise, false.
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.ArgumentNullException id is null.
System.ArgumentException id is an empty string.
System.InvalidOperationException The session could not be found.
| Improve this Doc View Source

SendTo(Byte[], String)

Sends data to the client using the specified session.
Declaration
public void SendTo(byte[] data, string id)
Parameters
Type Name Description
System.Byte[] data An array of System.Byte that represents the binary data to send.
System.String id A System.String that represents the ID of the session.
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.ArgumentNullException

id is null.

-or-

data is null.

System.ArgumentException id is an empty string.
System.InvalidOperationException

The session could not be found.

-or-

The current state of the WebSocket connection is not Open.

| Improve this Doc View Source

SendTo(Stream, Int32, String)

Sends the data from stream to the client using the specified session.
Declaration
public void SendTo(Stream stream, int length, string id)
Parameters
Type Name Description
System.IO.Stream stream A System.IO.Stream instance from which to read the data to send.
System.Int32 length An System.Int32 that specifies the number of bytes to send.
System.String id A System.String that represents the ID of the session.
Remarks
The data is sent as the binary data.
Exceptions
Type Condition
System.ArgumentNullException

id is null.

-or-

stream is null.

System.ArgumentException

id is an empty string.

-or-

stream cannot be read.

-or-

length is less than 1.

-or-

No data could be read from stream.

System.InvalidOperationException

The session could not be found.

-or-

The current state of the WebSocket connection is not Open.

| Improve this Doc View Source

SendTo(String, String)

Sends data to the client using the specified session.
Declaration
public void SendTo(string data, string id)
Parameters
Type Name Description
System.String data A System.String that represents the text data to send.
System.String id A System.String that represents the ID of the session.
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.ArgumentNullException

id is null.

-or-

data is null.

System.ArgumentException

id is an empty string.

-or-

data could not be UTF-8-encoded.

System.InvalidOperationException

The session could not be found.

-or-

The current state of the WebSocket connection is not Open.

| Improve this Doc View Source

SendToAsync(Byte[], String, Action<Boolean>)

Sends data asynchronously to the client using the specified session.
Declaration
public void SendToAsync(byte[] data, string id, Action<bool> completed)
Parameters
Type Name Description
System.Byte[] data An array of System.Byte that represents the binary data to send.
System.String id A System.String that represents the ID of the session.
System.Action<System.Boolean> completed

An Action<bool> delegate or null if not needed.

The delegate invokes the method called when the send is complete.

true is passed to the method if the send has done with no error; otherwise, false.

Remarks
This method does not wait for the send to be complete.
Exceptions
Type Condition
System.ArgumentNullException

id is null.

-or-

data is null.

System.ArgumentException id is an empty string.
System.InvalidOperationException

The session could not be found.

-or-

The current state of the WebSocket connection is not Open.

| Improve this Doc View Source

SendToAsync(Stream, Int32, String, Action<Boolean>)

Sends the data from stream asynchronously to the client using the specified session.
Declaration
public void SendToAsync(Stream stream, int length, string id, Action<bool> completed)
Parameters
Type Name Description
System.IO.Stream stream A System.IO.Stream instance from which to read the data to send.
System.Int32 length An System.Int32 that specifies the number of bytes to send.
System.String id A System.String that represents the ID of the session.
System.Action<System.Boolean> completed

An Action<bool> delegate or null if not needed.

The delegate invokes the method called when the send is complete.

true is passed to the method if the send has done with no error; otherwise, false.

Remarks

The data is sent as the binary data.

This method does not wait for the send to be complete.

Exceptions
Type Condition
System.ArgumentNullException

id is null.

-or-

stream is null.

System.ArgumentException

id is an empty string.

-or-

stream cannot be read.

-or-

length is less than 1.

-or-

No data could be read from stream.

System.InvalidOperationException

The session could not be found.

-or-

The current state of the WebSocket connection is not Open.

| Improve this Doc View Source

SendToAsync(String, String, Action<Boolean>)

Sends data asynchronously to the client using the specified session.
Declaration
public void SendToAsync(string data, string id, Action<bool> completed)
Parameters
Type Name Description
System.String data A System.String that represents the text data to send.
System.String id A System.String that represents the ID of the session.
System.Action<System.Boolean> completed

An Action<bool> delegate or null if not needed.

The delegate invokes the method called when the send is complete.

true is passed to the method if the send has done with no error; otherwise, false.

Remarks
This method does not wait for the send to be complete.
Exceptions
Type Condition
System.ArgumentNullException

id is null.

-or-

data is null.

System.ArgumentException

id is an empty string.

-or-

data could not be UTF-8-encoded.

System.InvalidOperationException

The session could not be found.

-or-

The current state of the WebSocket connection is not Open.

| Improve this Doc View Source

Sweep()

Cleans up the inactive sessions in the WebSocket service.
Declaration
public void Sweep()
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
| Improve this Doc View Source

TryGetSession(String, out IWebSocketSession)

Tries to get the session instance with id.
Declaration
public bool TryGetSession(string id, out IWebSocketSession session)
Parameters
Type Name Description
System.String id A System.String that represents the ID of the session to find.
IWebSocketSession session

When this method returns, a IWebSocketSession instance or null if not found.

The session instance provides the function to access the information in the session.

Returns
Type Description
System.Boolean true if the session is successfully found; otherwise, false.
Remarks
This class manages the sessions in a WebSocket service provided by the WebSocketServer or .
Exceptions
Type Condition
System.ArgumentNullException id is null.
System.ArgumentException id is an empty string.

Extension Methods

Serializer.Save<T>(T, out Byte[], SerializerCompression)
Serializer.Save<T>(T, Stream, SerializerCompression)
Serializer.Save<T>(T, BinaryFormatter, Stream, SerializerCompression)
Serializer.Save<T>(T, String, SerializerCompression)
Serializer.Save<T>(T, String)
Matrix.Concatenate<T>(T, T[])
Matrix.Replace<T>(T, Object, Object)
DomainDataImporter.Import(Object, InputConfiguration)
ObjectSerialize.Serialize(Object)
Matrix.IsEqual(Object, Object, Decimal, Decimal)
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © MARS GROUP. HAW Hamburg