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
TypedEmitter<SessionEvents>
Implements
RpcContextAsyncDisposable
Properties
clientCapabilities
readonly clientCapabilities: CapabilitySet;Defined in: netconf/src/messages/session.ts:310
Capabilities we advertised.
logger
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
Accessors
advertisedCapabilities
Get Signature
get advertisedCapabilities(): CapabilitySet;Defined in: netconf/src/messages/session.ts:393
The capabilities exactly as the server advertised them in its hello.
Returns
baseVersion
Get Signature
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
serverCapabilities
Get Signature
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
The server's capabilities, after any corrections from the device profile.
Implementation of
sessionId
Get Signature
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
state
Get Signature
get state(): SessionState;Defined in: netconf/src/messages/session.ts:375
Where the session is in its life: open, closing or closed.
Returns
Methods
[asyncDispose]()
[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()
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
Returns
() => void
Implementation of
close()
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()
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
Returns
void
Inherited from
TypedEmitter.dispatch
listenerCount()
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()
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()
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()
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()
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
onNotification()
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
rpc()
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
warn()
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?
Returns
void