OSDP.Net 5.3.0-beta.3
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
ReplyTracker.cs
1using System;
2
3namespace OSDP.Net.Messages;
4
5internal class ReplyTracker
6{
7 private readonly OutgoingMessage _issuingCommand;
8 private readonly DeviceProxy _device;
9
10 public ReplyTracker(Guid connectionId, IncomingMessage replyMessage, OutgoingMessage issuingCommand,
11 DeviceProxy device)
12 {
13 ConnectionId = connectionId;
14 ReplyMessage = replyMessage;
15 _issuingCommand = issuingCommand;
16 _device = device;
17 }
18
19 public IncomingMessage ReplyMessage { get; }
20
21 public Guid ConnectionId { get; }
22
30 public bool IsValidReply => ReplyMessage.Address == _issuingCommand.Address && ReplyMessage.IsDataCorrect;
31
38 public bool MatchIssuingCommand(byte address, byte commandCode) =>
39 address.Equals(_issuingCommand.Address) && commandCode.Equals(_issuingCommand.Code);
40
44 public bool IsReplyToSecureChannelHandshake =>
45 _issuingCommand.Code is (byte)CommandType.SessionChallenge or (byte)CommandType.ServerCryptogram;
46
47 internal bool ValidateSecureChannelEstablishment()
48 {
49 if (!ReplyMessage.SecureCryptogramHasBeenAccepted())
50 {
51 return false;
52 }
53
54 _device.MessageSecureChannel.Establish(ReplyMessage.Payload);
55
56 return true;
57 }
58}
CommandType
Identifies the type of OSDP protocol command (ACU -> PD) message.
Definition CommandType.cs:7