Class Host
Implements
Inherited Members
Namespace: VoltRpc.Communication
Assembly: VoltRpc.dll
Syntax
public abstract class Host : IDisposable
Constructors
| Improve this Doc View SourceHost(ILogger, Int32)
Creates a new Host instance
Declaration
protected Host(ILogger logger = null, int bufferSize = 8000)
Parameters
Type | Name | Description |
---|---|---|
ILogger | logger | The ILogger to use |
Int32 | bufferSize | The initial size of the buffers |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Will throw if the buffer size is less then 16 |
Fields
| Improve this Doc View SourceBufferSize
This size of the buffer
Declaration
protected readonly int BufferSize
Field Value
Type | Description |
---|---|
Int32 |
DefaultBufferSize
The default size of the buffers
Declaration
public const int DefaultBufferSize = 8000
Field Value
Type | Description |
---|---|
Int32 |
Logger
Logger
Declaration
protected readonly ILogger Logger
Field Value
Type | Description |
---|---|
ILogger |
Properties
| Improve this Doc View SourceConnectionCount
Count of number of connections
Declaration
public int ConnectionCount { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
HasDisposed
Has this object been disposed
Declaration
public bool HasDisposed { get; }
Property Value
Type | Description |
---|---|
Boolean |
HideStacktrace
Hides the stacktrace from the client when an Exception is thrown
Declaration
public bool HideStacktrace { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
IsRunning
Is the Host running?
Declaration
public bool IsRunning { get; protected set; }
Property Value
Type | Description |
---|---|
Boolean |
MaxConnectionsCount
What is the maximum amount of connections
Declaration
public int MaxConnectionsCount { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if value is 0 or less |
TypeReaderWriterManager
The TypeReaderWriterManager for Host
Declaration
public TypeReaderWriterManager TypeReaderWriterManager { get; }
Property Value
Type | Description |
---|---|
TypeReaderWriterManager |
Methods
| Improve this Doc View SourceAddService(Type, Object)
Adds a service to this Host
Declaration
public void AddService(Type serviceType, object serviceObject)
Parameters
Type | Name | Description |
---|---|---|
Type | serviceType | The Type of a service |
Object | serviceObject | The actual service Object itself |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the service has already been added |
ArgumentOutOfRangeException | Thrown if serviceType is not an interface |
AddService<T>(T)
Adds a service to this Host
Declaration
public void AddService<T>(T service)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | service | The service Object to add |
Type Parameters
Name | Description |
---|---|
T | The service type |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the service has already been added |
ArgumentOutOfRangeException | Thrown if T is not an interface |
CheckDispose()
Checks if the object has been disposed
Declaration
protected void CheckDispose()
Exceptions
Type | Condition |
---|---|
ObjectDisposedException |
Dispose()
Destroys the Host instance
Declaration
public virtual void Dispose()
ProcessRequest(Stream, Stream)
Processes a request from a client
This override will automatically create the BufferedReader and BufferedWriter for you then call ProcessRequest(BufferedReader, BufferedWriter).
This is the preferred process request method to call.
Declaration
protected void ProcessRequest(Stream readStream, Stream writeStream)
Parameters
Type | Name | Description |
---|---|---|
Stream | readStream | The Stream to read from |
Stream | writeStream | The Stream to write to |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if either provide stream is null |
ArgumentOutOfRangeException | Thrown if we can't read or write to the respected stream |
ProcessRequest(BufferedReader, BufferedWriter)
Processes a request from a client
You should only call this if you need to provide a custom BufferedReader and/or BufferedWriter. For example you are using a Stream that needs Position.
Declaration
protected void ProcessRequest(BufferedReader reader, BufferedWriter writer)
Parameters
Type | Name | Description |
---|---|---|
BufferedReader | reader | The BufferedReader to read from |
BufferedWriter | writer | The BufferedWriter to write to |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if either buffer is null |
StartListening()
Starts the Host to listen for requests
Declaration
public abstract Task StartListening()
Returns
Type | Description |
---|---|
Task |