Class BasePeriodicWebSocketListener<TReturnDataType, TStateType>
Starts sending data over a web socket periodically when a message is received, and then stops when a corresponding stop message is received
Inheritance
System.Object
BasePeriodicWebSocketListener<TReturnDataType, TStateType>
Namespace: MediaBrowser.Controller.Net
Assembly: MediaBrowser.Controller.dll
Syntax
public abstract class BasePeriodicWebSocketListener<TReturnDataType, TStateType> : IWebSocketListener, IDisposable where TReturnDataType : class where TStateType : WebSocketListenerState, new()
Type Parameters
Name | Description |
---|---|
TReturnDataType | The type of the T return data type. |
TStateType | The type of the T state type. |
Constructors
BasePeriodicWebSocketListener(ILogger)
Declaration
protected BasePeriodicWebSocketListener(ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger |
Fields
ActiveConnections
The _active connections
Declaration
protected readonly List<Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>> ActiveConnections
Field Value
Type | Description |
---|---|
System.Collections.Generic.List<System.Tuple<IWebSocketConnection, System.Threading.CancellationTokenSource, TStateType>> |
Logger
The logger
Declaration
protected ILogger Logger
Field Value
Type | Description |
---|---|
ILogger |
Properties
Name
Gets the name.
Declaration
protected abstract string Name { get; }
Property Value
Type | Description |
---|---|
System.String | The name. |
SendOnInitialConnection
Declaration
protected virtual bool SendOnInitialConnection { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(Boolean)
Releases unmanaged and - optionally - managed resources.
Declaration
protected virtual void Dispose(bool dispose)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | dispose |
|
GetActiveConnectionsToSendTo(Boolean)
Declaration
protected List<Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>> GetActiveConnectionsToSendTo(bool force)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | force |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.Tuple<IWebSocketConnection, System.Threading.CancellationTokenSource, TStateType>> |
GetDataToSend(IWebSocketConnection, TStateType, CancellationToken)
Gets the data to send.
Declaration
protected abstract Task<TReturnDataType> GetDataToSend(IWebSocketConnection connection, TStateType state, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IWebSocketConnection | connection | |
TStateType | state | The state. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TReturnDataType> | Task{`1}. |
ParseMessageParams(String[], TStateType)
Declaration
protected virtual void ParseMessageParams(string[] values, TStateType state)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | values | |
TStateType | state |
ProcessMessage(WebSocketMessageInfo)
Processes the message.
Declaration
public Task ProcessMessage(WebSocketMessageInfo message)
Parameters
Type | Name | Description |
---|---|---|
WebSocketMessageInfo | message | The message. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task. |
SendData(Boolean)
Declaration
protected void SendData(bool force)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | force |
SendData(Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>, TReturnDataType)
Declaration
protected async Task SendData(Tuple<IWebSocketConnection, CancellationTokenSource, TStateType> tuple, TReturnDataType data)
Parameters
Type | Name | Description |
---|---|---|
System.Tuple<IWebSocketConnection, System.Threading.CancellationTokenSource, TStateType> | tuple | |
TReturnDataType | data |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Implements
System.IDisposable