Class WebSocketServiceManager
Inheritance
Inherited Members
Namespace: Mars.Common.Socket.Server
Assembly: Mars.Common.dll
Syntax
public class WebSocketServiceManager
Remarks
Properties
| Improve this Doc View SourceCount
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | An System.Int32 that represents the number of the services. |
Remarks
Hosts
Declaration
public IEnumerable<WebSocketServiceHost> Hosts { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<WebSocketServiceHost> |
An It provides an enumerator which supports the iteration over the collection of the host instances. |
Remarks
Item[String]
path
.
Declaration
public WebSocketServiceHost this[string path] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | path | A System.String that represents an absolute path to the service to find. |
Property Value
Type | Description |
---|---|
WebSocketServiceHost |
A WebSocketServiceHost instance or null if not found. That host instance provides the function to access the information in the service. |
Remarks
path
is converted to a URL-decoded string and
/ is trimmed from the end of the converted string if any.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
path is null.
|
System.ArgumentException |
-or-
-or-
|
KeepClean
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
Paths
Declaration
public IEnumerable<string> Paths { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> |
An It provides an enumerator which supports the iteration over the collection of the paths. |
Remarks
SessionCount
Declaration
[Obsolete("This property will be removed.")]
public int SessionCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 | An System.Int32 that represents the total number of the sessions in the services. |
Remarks
WaitTime
Declaration
public TimeSpan WaitTime { get; set; }
Property Value
Type | Description |
---|---|
System.TimeSpan | A System.TimeSpan to wait for the response. |
Remarks
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The value specified for a set operation is zero or less. |
Methods
| Improve this Doc View SourceAddService<TBehavior>(String, Action<TBehavior>)
path
, and initializer
.
Declaration
public void AddService<TBehavior>(string path, Action<TBehavior> initializer)
where TBehavior : WebSocketBehavior, new()
Parameters
Type | Name | Description |
---|---|---|
System.String | path | A System.String that represents an absolute path to the service to add. |
System.Action<TBehavior> | initializer |
An That delegate invokes the method called for initializing a new session instance for the service. |
Type Parameters
Name | Description |
---|---|
TBehavior | The type of the behavior for the service. It must inherit the WebSocketBehavior class and it must have a public parameterless constructor. |
Remarks
path
is converted to a URL-decoded string and
/ is trimmed from the end of the converted string if any.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
path is null.
|
System.ArgumentException |
-or-
-or-
-or-
|
Broadcast(Byte[])
data
to every client in the WebSocket services.
Declaration
[Obsolete("This method will be removed.")]
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
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The current state of the manager is not Start. |
System.ArgumentNullException |
data is null.
|
Broadcast(String)
data
to every client in the WebSocket services.
Declaration
[Obsolete("This method will be removed.")]
public void Broadcast(string data)
Parameters
Type | Name | Description |
---|---|---|
System.String | data | A System.String that represents the text data to send. |
Remarks
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.
|
BroadcastAsync(Byte[], Action)
data
asynchronously to every client in
the WebSocket services.
Declaration
[Obsolete("This method will be removed.")]
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
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The current state of the manager is not Start. |
System.ArgumentNullException |
data is null.
|
BroadcastAsync(Stream, Int32, Action)
stream
asynchronously to
every client in the WebSocket services.
Declaration
[Obsolete("This method will be removed.")]
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 |
-or-
-or-
No data could be read from |
BroadcastAsync(String, Action)
data
asynchronously to every client in
the WebSocket services.
Declaration
[Obsolete("This method will be removed.")]
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
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.
|
Broadping()
Declaration
[Obsolete("This method will be removed.")]
public Dictionary<string, Dictionary<string, bool>> Broadping()
Returns
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.Dictionary<System.String, System.Boolean>> |
A It represents a collection of pairs of a service path and another collection of pairs of a session ID and a value indicating whether a pong has been received from the client within a time. |
Remarks
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The current state of the manager is not Start. |
Broadping(String)
message
to every client in
the WebSocket services.
Declaration
[Obsolete("This method will be removed.")]
public Dictionary<string, 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.Collections.Generic.Dictionary<System.String, System.Boolean>> |
A It represents a collection of pairs of a service path and another collection of pairs of a session ID and a value indicating whether a pong has been received from the client within a time. |
Remarks
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.
|
Clear()
Declaration
public void Clear()
Remarks
RemoveService(String)
path
.
Declaration
public bool RemoveService(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | A System.String that represents an absolute path to the service to remove. |
Returns
Type | Description |
---|---|
System.Boolean |
true if the service is successfully found and removed;
otherwise, false .
|
Remarks
path
is converted to a URL-decoded string and
/ is trimmed from the end of the converted string if any.
The service is stopped with close status 1001 (going away) if it has already started.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
path is null.
|
System.ArgumentException |
-or-
-or-
|
TryGetServiceHost(String, out WebSocketServiceHost)
path
.
Declaration
public bool TryGetServiceHost(string path, out WebSocketServiceHost host)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | A System.String that represents an absolute path to the service to find. |
WebSocketServiceHost | host |
When this method returns, a WebSocketServiceHost instance or null if not found. That host instance provides the function to access the information in the service. |
Returns
Type | Description |
---|---|
System.Boolean |
true if the service is successfully found;
otherwise, false .
|
Remarks
path
is converted to a URL-decoded string and
/ is trimmed from the end of the converted string if any.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
path is null.
|
System.ArgumentException |
-or-
-or-
|