2
2
* Copyright (c) 2005-2020 The OPC Foundation, Inc. All rights reserved.
3
3
*
4
4
* OPC Foundation MIT License 1.00
5
- *
5
+ *
6
6
* Permission is hereby granted, free of charge, to any person
7
7
* obtaining a copy of this software and associated documentation
8
8
* files (the "Software"), to deal in the Software without
11
11
* copies of the Software, and to permit persons to whom the
12
12
* Software is furnished to do so, subject to the following
13
13
* conditions:
14
- *
14
+ *
15
15
* The above copyright notice and this permission notice shall be
16
16
* included in all copies or substantial portions of the Software.
17
17
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32
32
using System . Linq ;
33
33
using System . Security . Cryptography . X509Certificates ;
34
34
using Opc . Ua ;
35
+ using Opc . Ua . Configuration ;
35
36
using Opc . Ua . Server ;
37
+ using Opc . Ua . Server . NodeManager ;
36
38
37
39
namespace Quickstarts . ReferenceServer
38
40
{
@@ -43,12 +45,23 @@ namespace Quickstarts.ReferenceServer
43
45
/// Each server instance must have one instance of a StandardServer object which is
44
46
/// responsible for reading the configuration file, creating the endpoints and dispatching
45
47
/// incoming requests to the appropriate handler.
46
- ///
48
+ ///
47
49
/// This sub-class specifies non-configurable metadata such as Product Name and initializes
48
50
/// the EmptyNodeManager which provides access to the data exposed by the Server.
49
51
/// </remarks>
50
- public partial class ReferenceServer : ReverseConnectServer
52
+ public partial class ReferenceServer : ReverseConnectServer , IReferenceServer
51
53
{
54
+ public ReferenceServer (
55
+ IApplicationInstance applicationInstance ,
56
+ IServerInternal serverInternal ,
57
+ IMainNodeManagerFactory mainNodeManagerFactory )
58
+ : base ( applicationInstance , serverInternal , mainNodeManagerFactory )
59
+ {
60
+ m_applicationInstance = applicationInstance ;
61
+ m_serverInternal = serverInternal ;
62
+ m_mainNodeManagerFactory = mainNodeManagerFactory ;
63
+ }
64
+
52
65
#region Properties
53
66
public ITokenValidator TokenValidator { get ; set ; }
54
67
@@ -63,7 +76,9 @@ public partial class ReferenceServer : ReverseConnectServer
63
76
/// always creates a CoreNodeManager which handles the built-in nodes defined by the specification.
64
77
/// Any additional NodeManagers are expected to handle application specific nodes.
65
78
/// </remarks>
66
- protected override MasterNodeManager CreateMasterNodeManager ( IServerInternal server , ApplicationConfiguration configuration )
79
+ protected override IMasterNodeManager CreateMasterNodeManager (
80
+ IServerInternal server ,
81
+ ApplicationConfiguration configuration )
67
82
{
68
83
Utils . LogInfo ( Utils . TraceMasks . StartStop , "Creating the Reference Server Node Manager." ) ;
69
84
@@ -78,7 +93,7 @@ protected override MasterNodeManager CreateMasterNodeManager(IServerInternal ser
78
93
}
79
94
80
95
// create master node manager.
81
- return new MasterNodeManager ( server , configuration , null , nodeManagers . ToArray ( ) ) ;
96
+ return m_mainNodeManagerFactory . CreateMasterNodeManager ( null , nodeManagers . ToArray ( ) ) ;
82
97
}
83
98
84
99
/// <summary>
@@ -127,7 +142,7 @@ protected override ResourceManager CreateResourceManager(IServerInternal server,
127
142
/// Initializes the server before it starts up.
128
143
/// </summary>
129
144
/// <remarks>
130
- /// This method is called before any startup processing occurs. The sub-class may update the
145
+ /// This method is called before any startup processing occurs. The sub-class may update the
131
146
/// configuration object or do any other application specific startup tasks.
132
147
/// </remarks>
133
148
protected override void OnServerStarting ( ApplicationConfiguration configuration )
@@ -153,11 +168,10 @@ protected override void OnServerStarted(IServerInternal server)
153
168
154
169
try
155
170
{
156
- lock ( ServerInternal . Status . Lock )
157
- {
158
- // allow a faster sampling interval for CurrentTime node.
159
- ServerInternal . Status . Variable . CurrentTime . MinimumSamplingInterval = 250 ;
160
- }
171
+ ServerInternal . UpdateServerStatus (
172
+ ( serverStatus ) => {
173
+ serverStatus . Variable . CurrentTime . MinimumSamplingInterval = 250 ;
174
+ } ) ;
161
175
}
162
176
catch
163
177
{ }
@@ -407,7 +421,7 @@ private IUserIdentity VerifyIssuedToken(IssuedIdentityToken issuedToken)
407
421
info = new TranslationInfo ( "IssuedTokenInvalid" , "en-US" , "token is an invalid issued token." ) ;
408
422
result = StatusCodes . BadIdentityTokenInvalid ;
409
423
}
410
- else // Rejected
424
+ else // Rejected
411
425
{
412
426
// construct translation object with default text.
413
427
info = new TranslationInfo ( "IssuedTokenRejected" , "en-US" , "token is rejected." ) ;
@@ -425,6 +439,10 @@ private IUserIdentity VerifyIssuedToken(IssuedIdentityToken issuedToken)
425
439
426
440
#region Private Fields
427
441
private ICertificateValidator m_userCertificateValidator ;
442
+ private readonly IMainNodeManagerFactory m_mainNodeManagerFactory ;
443
+ private readonly IServerInternal m_serverInternal ;
444
+ private readonly IApplicationInstance m_applicationInstance ;
445
+
428
446
#endregion
429
447
}
430
448
}
0 commit comments