Skip to content

Commit

Permalink
make ServerEngine async 5
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Jun 21, 2023
1 parent d828855 commit 29b18e3
Show file tree
Hide file tree
Showing 7 changed files with 450 additions and 506 deletions.
393 changes: 390 additions & 3 deletions packages/node-opcua-server/source/addressSpace_accessor.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions packages/node-opcua-server/source/i_address_space_accessor.ts
@@ -0,0 +1,12 @@
import { ISessionContext } from "node-opcua-address-space-base";
import { DataValue } from "node-opcua-data-value";
import { StatusCode } from "node-opcua-status-code";
import { BrowseDescriptionOptions, BrowseResult, ReadRequestOptions, WriteValue, CallMethodRequest, CallMethodResultOptions, HistoryReadRequest, HistoryReadResult } from "node-opcua-types";

export interface IAddressSpaceAccessor {
browse(context: ISessionContext, nodesToBrowse: BrowseDescriptionOptions[]): Promise<BrowseResult[]>;
read(context: ISessionContext, readRequest: ReadRequestOptions): Promise<DataValue[]>;
write(context: ISessionContext, nodesToWrite: WriteValue[]): Promise<StatusCode[]>;
call(context: ISessionContext, methodsToCall: CallMethodRequest[]): Promise<CallMethodResultOptions[]>;
historyRead(context: ISessionContext, historyReadRequest: HistoryReadRequest): Promise<HistoryReadResult[]>;
}
4 changes: 2 additions & 2 deletions packages/node-opcua-server/source/monitored_item.ts
Expand Up @@ -54,7 +54,7 @@ import { sameVariant, Variant, VariantArrayType } from "node-opcua-variant";

import { appendToTimer, removeFromTimer } from "./node_sampler";
import { validateFilter } from "./validate_filter";
import { checkWhereClauseOnAdressSpace } from "./filter/check_where_clause_on_address_space";
import { checkWhereClauseOnAdressSpace as checkWhereClauseOnAddressSpace } from "./filter/check_where_clause_on_address_space";
import { SamplingFunc } from "./sampling_func";

export type QueueItem = MonitoredItemNotification | EventFieldList;
Expand Down Expand Up @@ -991,7 +991,7 @@ export class MonitoredItem extends EventEmitter {

const addressSpace: AddressSpace = eventData.$eventDataSource?.addressSpace as AddressSpace;

if (!checkWhereClauseOnAdressSpace(addressSpace, SessionContext.defaultContext, this.filter.whereClause, eventData)) {
if (!checkWhereClauseOnAddressSpace(addressSpace, SessionContext.defaultContext, this.filter.whereClause, eventData)) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/node-opcua-server/source/opcua_server.ts
Expand Up @@ -2659,7 +2659,7 @@ export class OPCUAServer extends OPCUABaseServer {

// ask for a refresh of asynchronous variables
this.engine.refreshValues(request.nodesToRead, request.maxAge, (err?: Error | null) => {
assert(!err, " error not handled here , fix me");

this.engine.read(context, request).then((results) => {
assert(results[0].schema.name === "DataValue");
assert(results.length === request.nodesToRead!.length);
Expand Down Expand Up @@ -3365,7 +3365,7 @@ export class OPCUAServer extends OPCUABaseServer {

const context = session.sessionContext;
this.engine
.callMethods(context, request.methodsToCall)
.call(context, request.methodsToCall)
.then((results) => {
const response = new CallResponse({ results });
filterDiagnosticInfo(request.requestHeader.returnDiagnostics, response);
Expand Down
Expand Up @@ -10,7 +10,6 @@ import { assert } from "node-opcua-assert";
import { ErrorCallback, UAString } from "node-opcua-basic-types";
import {
coerceLocalizedText,
LocalizedTextLike,
LocalizedTextOptions,
OPCUAClientBase,
OPCUAClientBaseOptions,
Expand Down

0 comments on commit 29b18e3

Please sign in to comment.