Skip to content

Conversation

@Lessi30
Copy link
Contributor

@Lessi30 Lessi30 commented Dec 11, 2025

Proposed changes

The problem is that as a server, you don't automatically notice when something changes in a session. To avoid having to poll regularly at intervals, I introduced this event. It is triggered when the diagnostic counters of the session are updated. It also makes it easy to get the affected session updated. With polling, I would have to do this for every active session.

Related Issues

  • (Could open one if you don't want this change)

Types of changes

What types of changes does your code introduce?

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

@CLAassistant
Copy link

CLAassistant commented Dec 11, 2025

CLA assistant check
All committers have signed the CLA.

@romanett
Copy link
Contributor

@Lessi30 I am not to sure about the naming of this event. This will be invoked for every service call related to the Session, I would not consider that an update to the Session. Maybe you name it more like SessionActivity or SessionDiagnosticsChanged

@marcschier marcschier requested a review from Copilot December 11, 2025 18:19
@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.96%. Comparing base (d25caff) to head (4218bb3).
⚠️ Report is 55 commits behind head on master.

Files with missing lines Patch % Lines
Libraries/Opc.Ua.Server/Session/SessionManager.cs 57.14% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3407      +/-   ##
==========================================
+ Coverage   51.86%   59.96%   +8.09%     
==========================================
  Files         370      377       +7     
  Lines       78618    78749     +131     
  Branches    13650    13714      +64     
==========================================
+ Hits        40779    47218    +6439     
+ Misses      33705    27156    -6549     
- Partials     4134     4375     +241     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new SessionUpdated event to the OPC UA server's session management infrastructure to notify when diagnostic counters change. The feature allows server applications to react to session changes without polling, by subscribing to the event that fires whenever a session's diagnostic counters are updated.

Key changes:

  • Added SessionUpdated event to ISessionManager interface and SessionManager implementation
  • Added SessionEventReason.Updated enum value for the new event type
  • Implemented UpdateSession() method to trigger the event
  • Modified UpdateDiagnosticCounters() to automatically raise the event on every request

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
Libraries/Opc.Ua.Server/Session/ISessionManager.cs Adds SessionUpdated event declaration, Updated enum value, and UpdateSession method to interface
Libraries/Opc.Ua.Server/Session/SessionManager.cs Implements SessionUpdated event with thread-safe handlers, UpdateSession method, and routing in RaiseSessionEvent
Libraries/Opc.Ua.Server/Session/Session.cs Triggers UpdateSession call at the end of UpdateDiagnosticCounters method

@marcschier marcschier marked this pull request as draft December 11, 2025 19:02
@Lessi30 Lessi30 force-pushed the master branch 2 times, most recently from 63e0fad to 9ff1979 Compare December 12, 2025 14:56
@larws
Copy link
Contributor

larws commented Dec 15, 2025

@marcschier, @romanett What's missing here to get this PR on its way?

@romanett romanett marked this pull request as ready for review December 15, 2025 09:40
@romanett
Copy link
Contributor

@Lessi30 please add a Test that ensures the Event is triggered correctly then we can merge this imo

@Lessi30
Copy link
Contributor Author

Lessi30 commented Dec 15, 2025

@Lessi30 please add a Test that ensures the Event is triggered correctly then we can merge this imo

Done

@Lessi30
Copy link
Contributor Author

Lessi30 commented Dec 16, 2025

Is there anything else I need to do to ensure that the final pending check is successful? Or is it beyond my control?

@romanett
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mrsuciu mrsuciu merged commit a84c812 into OPCFoundation:master Dec 16, 2025
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants