• 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 WebSocketBehavior

Exposes the methods and properties used to define the behavior of a WebSocket service provided by the WebSocketServer or .
Inheritance
System.Object
WebSocketBehavior
Implements
IWebSocketSession
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 abstract class WebSocketBehavior : IWebSocketSession
Remarks
The WebSocketBehavior class is an abstract class.

Constructors

| Improve this Doc View Source

WebSocketBehavior()

Initializes a new instance of the WebSocketBehavior class.
Declaration
protected WebSocketBehavior()
Remarks
The WebSocketBehavior class is an abstract class.

Properties

| Improve this Doc View Source

Context

Gets the information in a handshake request to the WebSocket service.
Declaration
public WebSocketContext Context { get; }
Property Value
Type Description
WebSocketContext A WebSocketContext instance that provides the access to the handshake request, or null if the WebSocket connection isn't established.
Remarks
The WebSocketBehavior class is an abstract class.
| Improve this Doc View Source

EmitOnPing

Gets or sets a value indicating whether the WebSocket used in a session emits a OnMessage event when receives a Ping.
Declaration
public bool EmitOnPing { get; set; }
Property Value
Type Description
System.Boolean true if the WebSocket emits a OnMessage event when receives a Ping; otherwise, false. The default value is false.
Remarks
The WebSocketBehavior class is an abstract class.
| Improve this Doc View Source

ID

Gets the unique ID of a session.
Declaration
public string ID { get; }
Property Value
Type Description
System.String A System.String that represents the unique ID of the session, or null if the WebSocket connection isn't established.
Remarks
The WebSocketBehavior class is an abstract class.
| Improve this Doc View Source

IgnoreExtensions

Gets or sets a value indicating whether the WebSocket service ignores the Sec-WebSocket-Extensions header included in a handshake request.
Declaration
public bool IgnoreExtensions { get; set; }
Property Value
Type Description
System.Boolean true if the WebSocket service ignores the extensions requested from a client; otherwise, false. The default value is false.
Remarks
The WebSocketBehavior class is an abstract class.
| Improve this Doc View Source

OriginValidator

Gets or sets the delegate called to validate the Origin header included in a handshake request to the WebSocket service.
Declaration
public Func<string, bool> OriginValidator { get; set; }
Property Value
Type Description
System.Func<System.String, System.Boolean>

A Func<string, bool> delegate that references the method(s) used to validate the origin header.

System.String parameter passed to this delegate represents the value of the origin header to validate if any.

This delegate should return true if the origin header is valid.

The default value is null, and it does nothing to validate.

Remarks
This delegate is called when the WebSocket used in a session validates the handshake request.
| Improve this Doc View Source

Protocol

Gets or sets the WebSocket subprotocol used in the WebSocket service.
Declaration
public string Protocol { get; set; }
Property Value
Type Description
System.String

A System.String that represents the subprotocol if any. The default value is System.String.Empty.

The value to set must be a token defined in RFC 2616.

Remarks
Set operation of this property is available before the WebSocket connection has been established.
| Improve this Doc View Source

Sessions

Gets the access to the sessions in the WebSocket service.
Declaration
protected WebSocketSessionManager Sessions { get; }
Property Value
Type Description
WebSocketSessionManager A WebSocketSessionManager that provides the access to the sessions, or null if the WebSocket connection isn't established.
Remarks
The WebSocketBehavior class is an abstract class.
| Improve this Doc View Source

StartTime

Gets the time that a session has started.
Declaration
public DateTime StartTime { get; }
Property Value
Type Description
System.DateTime A System.DateTime that represents the time that the session has started, or System.DateTime.MaxValue if the WebSocket connection isn't established.
Remarks
The WebSocketBehavior class is an abstract class.
| Improve this Doc View Source

State

Gets the state of the WebSocket used in a session.
Declaration
public WebSocketState State { get; }
Property Value
Type Description
WebSocketState One of the WebSocketState enum values, indicates the state of the WebSocket.
Remarks
The WebSocketBehavior class is an abstract class.

Methods

| Improve this Doc View Source

Error(String, Exception)

Calls the OnError(ErrorEventArgs) method with the specified message and exception.
Declaration
protected void Error(string message, Exception exception)
Parameters
Type Name Description
System.String message A System.String that represents the error message.
System.Exception exception An System.Exception instance that represents the cause of the error if any.
Remarks
This method doesn't call the OnError(ErrorEventArgs) method if message is null or empty.
| Improve this Doc View Source

OnClose(CloseEventArgs)

Called when the WebSocket connection used in a session has been closed.
Declaration
protected virtual void OnClose(CloseEventArgs e)
Parameters
Type Name Description
CloseEventArgs e A CloseEventArgs that represents the event data passed to a OnClose event.
Remarks
The WebSocketBehavior class is an abstract class.
| Improve this Doc View Source

OnError(ErrorEventArgs)

Called when the WebSocket used in a session gets an error.
Declaration
protected virtual void OnError(ErrorEventArgs e)
Parameters
Type Name Description
ErrorEventArgs e A ErrorEventArgs that represents the event data passed to a OnError event.
Remarks
The WebSocketBehavior class is an abstract class.
| Improve this Doc View Source

OnMessage(MessageEventArgs)

Called when the WebSocket used in a session receives a message.
Declaration
protected virtual void OnMessage(MessageEventArgs e)
Parameters
Type Name Description
MessageEventArgs e A MessageEventArgs that represents the event data passed to a OnMessage event.
Remarks
The WebSocketBehavior class is an abstract class.
| Improve this Doc View Source

OnOpen()

Called when the WebSocket connection used in a session has been established.
Declaration
protected virtual void OnOpen()
Remarks
The WebSocketBehavior class is an abstract class.
| Improve this Doc View Source

Send(Byte[])

Sends binary data to the client on a session.
Declaration
protected void Send(byte[] data)
Parameters
Type Name Description
System.Byte[] data An array of System.Byte that represents the binary data to send.
Remarks
This method is available after the WebSocket connection has been established.
| Improve this Doc View Source

Send(FileInfo)

Sends the specified file as binary data to the client on a session.
Declaration
protected void Send(FileInfo file)
Parameters
Type Name Description
System.IO.FileInfo file A System.IO.FileInfo that represents the file to send.
Remarks
This method is available after the WebSocket connection has been established.
| Improve this Doc View Source

Send(String)

Sends text data to the client on a session.
Declaration
protected void Send(string data)
Parameters
Type Name Description
System.String data A System.String that represents the text data to send.
Remarks
This method is available after the WebSocket connection has been established.
| Improve this Doc View Source

SendAsync(Byte[], Action<Boolean>)

Sends binary data asynchronously to the client on a session.
Declaration
protected void SendAsync(byte[] data, Action<bool> completed)
Parameters
Type Name Description
System.Byte[] data An array of System.Byte that represents the binary data to send.
System.Action<System.Boolean> completed An Action<bool> delegate that references the method(s) called when the send is complete. A System.Boolean passed to this delegate is true if the send is complete successfully.
Remarks

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

| Improve this Doc View Source

SendAsync(FileInfo, Action<Boolean>)

Sends the specified file as binary data asynchronously to the client on a session.
Declaration
protected void SendAsync(FileInfo file, Action<bool> completed)
Parameters
Type Name Description
System.IO.FileInfo file A System.IO.FileInfo that represents the file to send.
System.Action<System.Boolean> completed An Action<bool> delegate that references the method(s) called when the send is complete. A System.Boolean passed to this delegate is true if the send is complete successfully.
Remarks

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

| Improve this Doc View Source

SendAsync(Stream, Int32, Action<Boolean>)

Sends binary data from the specified System.IO.Stream asynchronously to the client on a session.
Declaration
protected void SendAsync(Stream stream, int length, Action<bool> completed)
Parameters
Type Name Description
System.IO.Stream stream A System.IO.Stream from which contains the binary data to send.
System.Int32 length An System.Int32 that represents the number of bytes to send.
System.Action<System.Boolean> completed An Action<bool> delegate that references the method(s) called when the send is complete. A System.Boolean passed to this delegate is true if the send is complete successfully.
Remarks

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

| Improve this Doc View Source

SendAsync(String, Action<Boolean>)

Sends text data asynchronously to the client on a session.
Declaration
protected void SendAsync(string data, Action<bool> completed)
Parameters
Type Name Description
System.String data A System.String that represents the text data to send.
System.Action<System.Boolean> completed An Action<bool> delegate that references the method(s) called when the send is complete. A System.Boolean passed to this delegate is true if the send is complete successfully.
Remarks

This method is available after the WebSocket connection has been established.

This method doesn't wait for the send to be complete.

Implements

IWebSocketSession

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