Opc.Ua.Client.Session.OnKeepAliveComplete C# (CSharp) Method

OnKeepAliveComplete() private method

Checks if a notification has arrived. Sends a publish if it has not.
private OnKeepAliveComplete ( IAsyncResult result ) : void
result IAsyncResult
return void
        private void OnKeepAliveComplete(IAsyncResult result)
        {            
            ReadValueIdCollection nodesToRead = (ReadValueIdCollection)result.AsyncState;
         
            AsyncRequestCompleted(result, 0, DataTypes.ReadRequest);

            try
            {
                // read the server status.
                DataValueCollection values = new DataValueCollection();
                DiagnosticInfoCollection diagnosticInfos = new DiagnosticInfoCollection();

                ResponseHeader responseHeader = EndRead(
                    result,
                    out values,
                    out diagnosticInfos);
                
                ValidateResponse(values, nodesToRead);
                ValidateDiagnosticInfos(diagnosticInfos, nodesToRead);
                
                // validate value returned.
                ServiceResult error = ValidateDataValue(values[0], typeof(int), 0, diagnosticInfos, responseHeader);

                if (ServiceResult.IsBad(error))
                {
                    throw new ServiceResultException(error);
                }

                // send notification that keep alive completed.
                OnKeepAlive((ServerState)(int)values[0].Value, responseHeader.Timestamp);
            }
            catch (Exception e)
            { 
                Utils.Trace("Unexpected keep alive error occurred: {0}", e.Message);
            }
        }