OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
OSDP.Net.Connections.TcpServerOsdpConnection Class Reference

TCP server OSDP connection that allows a ControlPanel (ACU) to act as a TCP server, accepting connections from OSDP devices. More...

Inheritance diagram for OSDP.Net.Connections.TcpServerOsdpConnection:
OSDP.Net.Connections.OsdpConnection OSDP.Net.Connections.IOsdpConnection

Public Member Functions

 TcpServerOsdpConnection (int portNumber, int baudRate, ILoggerFactory loggerFactory=null)
 Initializes a new instance of the TcpServerOsdpConnection class.
override async Task Open ()
 Open the connection for communications.
override Task Close ()
 Close the connection for communications.
override async Task WriteAsync (byte[] buffer)
 Write to connection.
Parameters
bufferArray of bytes to write

override async Task< int > ReadAsync (byte[] buffer, CancellationToken token)
 Read from connection.
Parameters
bufferArray of bytes to read
tokenCancellation token to end reading of bytes
Returns
Number of actual bytes read

override string ToString ()
Public Member Functions inherited from OSDP.Net.Connections.OsdpConnection
Task Close ()
 Close the connection for communications.
Task Open ()
 Open the connection for communications.
Task< int > ReadAsync (byte[] buffer, CancellationToken token)
 Read from connection.
Parameters
bufferArray of bytes to read
tokenCancellation token to end reading of bytes
Returns
Number of actual bytes read

Task WriteAsync (byte[] buffer)
 Write to connection.
Parameters
bufferArray of bytes to write

void Dispose ()

Protected Member Functions

override void Dispose (bool disposing)
 Disposes the OsdpConnection instance.This method is responsible for releasing any resources used by the OsdpConnection instance. It calls the Close method to close the connection if it is open and sets the _disposedValue field to true to indicate that the instance has been disposed.
Protected Member Functions inherited from OSDP.Net.Connections.OsdpConnection
 OsdpConnection (int baudRate)
 Creates an instance of OsdpConnection.

Properties

override bool IsOpen [get]
 Is the connection open and ready to communicate.
Properties inherited from OSDP.Net.Connections.OsdpConnection
int BaudRate [get, protected set]
 Speed of the connection.
virtual bool IsOpen [get, protected set]
 Is the connection open and ready to communicate.
TimeSpan ReplyTimeout = TimeSpan.FromMilliseconds(200) [get, set]
 Timeout value waiting for a reply.

Detailed Description

TCP server OSDP connection that allows a ControlPanel (ACU) to act as a TCP server, accepting connections from OSDP devices.

This class combines TCP listening and connection handling in a single IOsdpConnection implementation, making it suitable for use with ControlPanel instances that need to accept incoming device connections. For scenarios where devices (PDs) need to accept ACU connections, use TcpConnectionListener instead.

Definition at line 19 of file TcpServerOsdpConnection.cs.

Constructor & Destructor Documentation

◆ TcpServerOsdpConnection()

OSDP.Net.Connections.TcpServerOsdpConnection.TcpServerOsdpConnection ( int portNumber,
int baudRate,
ILoggerFactory loggerFactory = null )
inline

Initializes a new instance of the TcpServerOsdpConnection class.

Parameters
portNumberThe TCP port number to listen on.
baudRateThe simulated baud rate for OSDP communication timing.
loggerFactoryOptional logger factory for diagnostic logging.

Definition at line 32 of file TcpServerOsdpConnection.cs.

References TcpServerOsdpConnection().

Referenced by TcpServerOsdpConnection().

Member Function Documentation

◆ Close()

override Task OSDP.Net.Connections.TcpServerOsdpConnection.Close ( )
inline

Close the connection for communications.

Implements OSDP.Net.Connections.IOsdpConnection.

Definition at line 73 of file TcpServerOsdpConnection.cs.

Referenced by Dispose(), and Open().

◆ Dispose()

override void OSDP.Net.Connections.TcpServerOsdpConnection.Dispose ( bool disposing)
inlineprotectedvirtual

Disposes the OsdpConnection instance.This method is responsible for releasing any resources used by the OsdpConnection instance. It calls the Close method to close the connection if it is open and sets the _disposedValue field to true to indicate that the instance has been disposed.

Reimplemented from OSDP.Net.Connections.OsdpConnection.

Definition at line 152 of file TcpServerOsdpConnection.cs.

References Close().

◆ Open()

override async Task OSDP.Net.Connections.TcpServerOsdpConnection.Open ( )
inline

Open the connection for communications.

Implements OSDP.Net.Connections.IOsdpConnection.

Definition at line 49 of file TcpServerOsdpConnection.cs.

References Close().

◆ ReadAsync()

override async Task< int > OSDP.Net.Connections.TcpServerOsdpConnection.ReadAsync ( byte[] buffer,
CancellationToken token )
inline

Read from connection.

Parameters
bufferArray of bytes to read
tokenCancellation token to end reading of bytes
Returns
Number of actual bytes read

Implements OSDP.Net.Connections.IOsdpConnection.

Definition at line 112 of file TcpServerOsdpConnection.cs.

◆ ToString()

override string OSDP.Net.Connections.TcpServerOsdpConnection.ToString ( )
inline

Definition at line 146 of file TcpServerOsdpConnection.cs.

◆ WriteAsync()

override async Task OSDP.Net.Connections.TcpServerOsdpConnection.WriteAsync ( byte[] buffer)
inline

Write to connection.

Parameters
bufferArray of bytes to write

Implements OSDP.Net.Connections.IOsdpConnection.

Definition at line 93 of file TcpServerOsdpConnection.cs.

Property Documentation

◆ IsOpen

override bool OSDP.Net.Connections.TcpServerOsdpConnection.IsOpen
get

Is the connection open and ready to communicate.

Implements OSDP.Net.Connections.IOsdpConnection.

Definition at line 39 of file TcpServerOsdpConnection.cs.


The documentation for this class was generated from the following file: