Skip to content

Class: Session ​

Defined in: netconf/src/messages/session.ts:303

A NETCONF session on one connection (RFC 6241 messages layer): it sends RPCs, matches replies and routes notifications. Open one with openSession; a client from connect() has one inside it. See Messages.

Extends ​

Implements ​

Properties ​

clientCapabilities ​

ts
readonly clientCapabilities: CapabilitySet;

Defined in: netconf/src/messages/session.ts:310

Capabilities we advertised.


logger ​

ts
readonly logger: Logger;

Defined in: netconf/src/messages/session.ts:317

The session's logger: one object whose methods follow the client's logger and log level as they change. Only enabled levels have a method.

Implementation of ​

RpcContext.logger

Accessors ​

advertisedCapabilities ​

Get Signature ​

ts
get advertisedCapabilities(): CapabilitySet;

Defined in: netconf/src/messages/session.ts:393

The capabilities exactly as the server advertised them in its hello.

Returns ​

CapabilitySet


baseVersion ​

Get Signature ​

ts
get baseVersion(): BaseVersion;

Defined in: netconf/src/messages/session.ts:398

The NETCONF base version in use: 1.1 (chunked framing) or 1.0 (EOM framing).

Returns ​

BaseVersion


serverCapabilities ​

Get Signature ​

ts
get serverCapabilities(): CapabilitySet;

Defined in: netconf/src/messages/session.ts:388

The server's capabilities, after any corrections from the hello hook (the device profile). Capability checks use these.

Returns ​

CapabilitySet

The server's capabilities, after any corrections from the device profile.

Implementation of ​

RpcContext.serverCapabilities


sessionId ​

Get Signature ​

ts
get sessionId(): number;

Defined in: netconf/src/messages/session.ts:380

The session-id the server assigned.

Returns ​

number

The session-id the server assigned.

Implementation of ​

RpcContext.sessionId


state ​

Get Signature ​

ts
get state(): SessionState;

Defined in: netconf/src/messages/session.ts:375

Where the session is in its life: open, closing or closed.

Returns ​

SessionState

Methods ​

[asyncDispose]() ​

ts
[asyncDispose](): Promise<void>;

Defined in: netconf/src/messages/session.ts:471

Close the session, for await using. Same as Session.close.

Returns ​

Promise<void>

Implementation of ​

AsyncDisposable.[asyncDispose]


addRpcGuard() ​

ts
addRpcGuard(guard): () => void;

Defined in: netconf/src/messages/session.ts:451

Check every operation before rpc() sends it. A guard refuses by throwing; rpc() then rejects with that error and sends nothing. <close-session> from close() is never guarded. Returns a function that removes the guard.

Parameters ​

guard ​

RpcGuard

Returns ​

() => void

Implementation of ​

RpcContext.addRpcGuard


close() ​

ts
close(): Promise<void>;

Defined in: netconf/src/messages/session.ts:465

Close the session: send <close-session>, wait briefly for the reply, then close the connection. Idempotent, and never rejects.

Returns ​

Promise<void>


dispatch() ​

ts
protected dispatch<K>(event, payload): void;

Defined in: netconf/src/messages/emitter.ts:51

Call every listener for event with payload, in the order they were added. For subclasses; a listener that throws is logged and skipped.

Type Parameters ​

K ​

K extends keyof SessionEvents

Parameters ​

event ​

K

payload ​

SessionEvents[K]

Returns ​

void

Inherited from ​

TypedEmitter.dispatch


listenerCount() ​

ts
listenerCount<K>(event): number;

Defined in: netconf/src/messages/emitter.ts:43

How many listeners event has.

Type Parameters ​

K ​

K extends keyof SessionEvents

Parameters ​

event ​

K

Returns ​

number

Inherited from ​

TypedEmitter.listenerCount


off() ​

ts
off<K>(event, listener): void;

Defined in: netconf/src/messages/emitter.ts:38

Remove a listener added with on(). Removing one that isn't there does nothing.

Type Parameters ​

K ​

K extends keyof SessionEvents

Parameters ​

event ​

K

listener ​

Listener<SessionEvents[K]>

Returns ​

void

Inherited from ​

TypedEmitter.off


on() ​

ts
on<K>(event, listener): () => void;

Defined in: netconf/src/messages/emitter.ts:18

Add a listener. Returns a function that removes it.

Type Parameters ​

K ​

K extends keyof SessionEvents

Parameters ​

event ​

K

listener ​

Listener<SessionEvents[K]>

Returns ​

() => void

Inherited from ​

TypedEmitter.on


once() ​

ts
once<K>(event, listener): () => void;

Defined in: netconf/src/messages/emitter.ts:29

Add a listener that runs at most once. Returns a function that removes it.

Type Parameters ​

K ​

K extends keyof SessionEvents

Parameters ​

event ​

K

listener ​

Listener<SessionEvents[K]>

Returns ​

() => void

Inherited from ​

TypedEmitter.once


onClosed() ​

ts
onClosed(listener): () => void;

Defined in: netconf/src/messages/session.ts:447

Call listener once when the session closes. Returns a function that stops it.

Parameters ​

listener ​

(event) => void

Returns ​

() => void

Implementation of ​

RpcContext.onClosed


onNotification() ​

ts
onNotification(listener): () => void;

Defined in: netconf/src/messages/session.ts:443

Call listener for every <notification> the session receives. Returns a function that stops it.

Parameters ​

listener ​

(notification) => void

Returns ​

() => void

Implementation of ​

RpcContext.onNotification


rpc() ​

ts
rpc(operation, options?): Promise<RpcReply>;

Defined in: netconf/src/messages/session.ts:430

Send any operation and wait for its reply.

Parameters ​

operation ​

string | XmlElement

The operation element (the content of <rpc>), or its XML text. Text is parsed first, so malformed XML is rejected locally. An element without a namespace is sent in the NETCONF base namespace.

options? ​

RpcOptions = {}

Returns ​

Promise<RpcReply>

Throws ​

RpcError if the reply contains an error-severity <rpc-error>.

Throws ​

TimeoutError, AbortError, SessionClosedError.

Implementation of ​

RpcContext.rpc


warn() ​

ts
warn(
   message, 
   cause?, 
   rpcError?
): void;

Defined in: netconf/src/messages/session.ts:720

Report something odd that didn't stop the session: log it as a warning and emit a warning event. Used by the layers above, such as JSON output falling back to a schema-less conversion.

Parameters ​

message ​

string

cause? ​

unknown

rpcError? ​

RpcErrorDetail

Returns ​

void

Released under the MIT Licence.