Exemple #1
0
 /// <summary>
 /// Constructs a new DeviceTableEntry instance
 /// </summary>
 /// <param name="instance">The device instance</param>
 /// <param name="address">The address of the device</param>
 /// <param name="maxAppgramLength">The maximum appgram length that this device can receive</param>
 /// <param name="segmentationSupport">The segmentation support of the device</param>
 /// <param name="vendorId">The vendor id of the device</param>
 public DeviceTableEntry(uint instance, Address address, uint maxAppgramLength, Segmentation segmentationSupport, ushort vendorId)
 {
     this.Instance = instance;
     this.Address = address;
     this.MaxAppgramLength = maxAppgramLength;
     this.SegmentationSupport = segmentationSupport;
     this.VendorId = vendorId;
 }
 /// <summary>
 /// Processes a received complex ack
 /// </summary>
 /// <param name="source">The address of the device that sent the ack</param>
 /// <param name="message">The complex ack header</param>
 /// <param name="segment">The buffer segment containing the ack content</param>
 public void ProcessComplexAck(Address source, ComplexAckMessage message, BufferSegment segment)
 {
     ClientTransaction tx = null;
     lock (_lock)
     {
         tx = _getClientTransaction(source, message.InvokeId);
     }
     if(tx != null)
         tx.OnComplexAck(message, segment);
 }
Exemple #3
0
 /// <summary>
 /// Gets a device table entry by address
 /// </summary>
 /// <param name="address">The device's address</param>
 /// <returns>The device table entry, or null if no entry exists</returns>
 public DeviceTableEntry GetByAddress(Address address)
 {
     for(int i = 0; i < _count; i++)
     {
         int index = (_start + i) % _entries.Length;
         var entry = _entries[index];
         if (entry != null && entry.Address == address)
             return entry;
     }
     return null;
 }
 /// <summary>
 /// Processes a received abortion
 /// </summary>
 /// <param name="source">The address of the device that sent the abortion</param>
 /// <param name="message">The abortion</param>
 public void ProcessAbort(Address source, AbortMessage message)
 {
     if (message.Server)
     {
         ClientTransaction tx = null;
         lock(_lock)
         {
             tx = _getClientTransaction(source, message.InvokeId);
         }
         if(tx != null)
             tx.OnAbort(message);
     }
 }
 /// <summary>
 /// Constructs a new inbound unconfirmed request
 /// </summary>
 /// <param name="sourceAddress">The device that sent the request</param>
 /// <param name="source">The device table entry of the device that sent the request</param>
 /// <param name="request">The request instance</param>
 public InboundUnconfirmedRequest(Address sourceAddress, DeviceTableEntry source, IUnconfirmedRequest request)
 {
     this.SourceAddress = sourceAddress;
     this.Source = source;
     this.Request = request;
 }
 /// <summary>
 /// Processes a received confirmed request
 /// </summary>
 /// <param name="source">The address of the device that sent the request</param>
 /// <param name="message">The confirmed request header</param>
 /// <param name="segment">The buffer segment containing the request content</param>
 public void ProcessConfirmedRequest(Address source, ConfirmedRequestMessage message, BufferSegment segment)
 {
 }
        /// <summary>
        /// Sends a confirmed request
        /// </summary>
        /// <param name="handle">The transaction handle</param>
        /// <param name="destination">The destination address</param>
        /// <param name="serviceChoice">The service choice of the request</param>
        /// <param name="request">The request to send</param>
        public void SendConfirmedRequest(ClientTransactionHandle handle, Address destination, byte serviceChoice, byte[] request)
        {
            lock(_lock)
            {
                byte invokeId = _getClientInvokeId();

                var transaction = new ClientTransaction(
                    _host,
                    this,
                    handle,
                    invokeId,
                    destination,
                    serviceChoice,
                    request);

                this._clientTransactions.Add(transaction);
            }
        }
 /// <summary>
 /// Gets the client transaction that matches
 /// a remote address, invoke id pair
 /// </summary>
 /// <param name="address">The remote address</param>
 /// <param name="invokeId">The invoke id</param>
 /// <returns>The client transaction, or null of no transaction exists</returns>
 private ClientTransaction _getClientTransaction(Address address, byte invokeId)
 {
     for(int i = 0; i < _clientTransactions.Count; i++)
     {
         var tx = _clientTransactions[i];
         if (tx.Matches(address, invokeId))
             return tx;
     }
     return null;
 }
 /// <summary>
 /// Processes a received simple ack
 /// </summary>
 /// <param name="source">The address of the device that sent the ack</param>
 /// <param name="message">The simple ack</param>
 public void ProcessSimpleAck(Address source, SimpleAckMessage message)
 {
     ClientTransaction tx = null;
     lock (_lock)
     {
         tx = _getClientTransaction(source, message.InvokeId);
     }
     if(tx != null)
         tx.OnSimpleAck(message);
 }
 /// <summary>
 /// Processes a received rejection
 /// </summary>
 /// <param name="source">The address of the device that sent the rejection</param>
 /// <param name="message">The rejection</param>
 public void ProcessReject(Address source, RejectMessage message)
 {
     ClientTransaction tx = null;
     lock (_lock)
     {
         tx = _getClientTransaction(source, message.InvokeId);
     }
     if(tx != null)
         tx.OnReject(message);
 }
 /// <summary>
 /// Processes a received error
 /// </summary>
 /// <param name="source">The address of the device that sent the error</param>
 /// <param name="message">The error</param>
 public void ProcessError(Address source, ErrorMessage message)
 {
     ClientTransaction tx = null;
     lock (_lock)
     {
         tx = _getClientTransaction(source, message.InvokeId);
     }
     if(tx != null)
         tx.OnError(message);
 }
Exemple #12
0
 /// <summary>
 /// Determines whether this transaction matches a supplied
 /// remote address and invoke id pair
 /// </summary>
 /// <param name="address">The remote address</param>
 /// <param name="invokeId">The invoke id</param>
 /// <returns>True if the transaction matches, false otherwise</returns>
 public bool Matches(Address address, byte invokeId)
 {
     var entry = this._device;
     if (entry == null)
         return false;
     return entry.Address == address && _invokeId == invokeId;
 }
Exemple #13
0
 /// <summary>
 /// Constructs a new ClientTransaction instance
 /// </summary>
 /// <param name="host">The host that initiated the transaction</param>
 /// <param name="manager">The transaction manager</param>
 /// <param name="handle">The handle used to control this transaction and process its response</param>
 /// <param name="invokeId">The invocation id for the transaction</param>
 /// <param name="deviceAddress">The address of the destination device</param>
 /// <param name="serviceChoice">The service choice of the request</param>
 /// <param name="request">The request content</param>
 public ClientTransaction(Host host, TransactionManager manager, ClientTransactionHandle handle, byte invokeId, Address deviceAddress, byte serviceChoice, byte[] request)
 {
     this._host = host;
     this._manager = manager;
     this._handle = handle;
     this._invokeId = invokeId;
     this._serviceChoice = serviceChoice;
     this._request = request;
     this._state = ClientState.GetDeviceInfo;
     this._handle.SetTransaction(this);
     host.SearchForDevice(deviceAddress, this);
 }