Options
All
  • Public
  • Public/Protected
  • All
Menu

Class InternalSessionImpl

Internal session implementation

Hierarchy

Implements

Index

Constructors

constructor

Properties

Private attempts

attempts: number

The number of reconnection attempts

Private Readonly connection

connection: Connection

The connection to the server

Private conversationSet

conversationSet: ConversationSet

The current conversation set

Private Readonly conversationSetFactory

conversationSetFactory: ConversationSetFactory

The factory for generating conversation sets

Private Readonly emitter

emitter: Emitter

The emitter to emit stream events on

Private Readonly fsm

fsm: FSM

The finite state machine that keeps track of the internal state

Private Readonly opts

The session options

Private principal

principal: string

The session principal

Private serverMaximumMessageSize

serverMaximumMessageSize: number

The server's maximum message size

Private Readonly serviceAdapter

serviceAdapter: ServiceAdapter

The service adapter

Private Readonly serviceLocator

serviceLocator: ServiceLocator

The service locator

Private Readonly serviceRegistry

serviceRegistry: ServiceRegistry

The service registry

Private sessionActivityMonitor

sessionActivityMonitor: SessionActivityMonitor

The session activity monitor

Private sessionActivityMonitorFactory

sessionActivityMonitorFactory: SessionActivityMonitorFactory

The session activity monitor factory

Private sessionID

sessionID: SessionId

The session ID

Private Readonly sessionLocksFeature

sessionLocksFeature: InternalSessionLocks

The session locks held by this session

Private token

token: string

The session token

Private Readonly topicCache

topicCache: TopicCache

The topic cache

Private Readonly topicRouting

topicRouting: TopicRouting

The router that routes incoming messages

Private Readonly topicStreamRegistry

topicStreamRegistry: StreamRegistryImpl

The registry for streams on topic values

Private Readonly transports

transports: Transports

The transports that are available for this session

Readonly version

version: string

The version of this client library in the form major.minor.patch

Accessors

Private sessionLocks

  • Returns InternalSessionLocks

Methods

Private abort

  • Cancel a reconnect event

    Parameters

    • Default value reason: CloseReason = CloseReasonEnum.RECONNECT_ABORTED

      the reason for closing

    Returns void

checkConnected

  • checkConnected(reject: (err: any) => void): boolean
  • Check if the session is connected

    If the session is not connected an error will be emitted on the session's stream

    Parameters

    • reject: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns boolean

    true if the finite state machine is in the connected state

close

connect

  • connect(): void
  • Attempt to connect to the server

    Returns void

error

  • Close the stream. This will emit a 'close' event to any assigned listeners. No further events will be emitted.

    Parameters

    Returns Stream

getContext

getConversationSet

getErrorHandler

  • getErrorHandler(): (Anonymous function)
  • Get the error handler

    Returns (Anonymous function)

    a handler that logs the error in the error logs

getOptions

  • Get the session's options

    Returns OptionsImpl

    the options

getPrincipal

  • getPrincipal(): string
  • Get the session principal

    Returns string

    the session principal

getRouting

  • Get the topic router

    Returns TopicRouting

    the topic router

getServerMaximumMessageSize

  • getServerMaximumMessageSize(): number

getServiceAdapter

  • Get the service adapter

    Returns ServiceAdapter

    the service adapter

getServiceLocator

getServiceRegistry

getSessionId

  • Get the session ID

    Returns SessionId

    the session ID

getState

  • Get the current state

    Returns InternalSessionState

    the state of the finite state machine

getStreamRegistry

Private internalClose

  • Close the session

    This will close all topic streams, discard all conversations and emit a close event on the session's stream

    Parameters

    • reason: CloseReason

      the reason for closing the session. This will be passed on to the stream close event.

    Returns void

isConnected

  • isConnected(): boolean
  • Query if the session is connected

    Returns boolean

    true if the finite state machine is in the connected state

isShared

  • isShared(): boolean
  • Query if the session is using a shared session

    Returns boolean

lock

  • Request a session lock

    Parameters

    Returns Promise<SessionLock>

    a Promise that resolves with the acquired session lock

off

  • Remove a listener from a specified event.

    Example:

    // Bind a single listener to the 'foo' event and then deregister it
    var listener = function() {};
    stream.on('foo', listener);
    stream.off('foo', listener);
    

    Example:

    // Bind a listener to the 'foo' event and deregister all listeners
    var listener = function() {};
    stream.on('foo', listener);
    stream.off('foo');
    

    Parameters

    • events: string | CallbackMap
    • Optional listener: StreamCallback

      the listener to remove. All listeners for the event are removed if this is not specified. This argument is ignored if the first argument is a CallbackMap.

    Returns Stream

    this stream.

on

  • Register listeners against events.

    A single listener may be bound to an event by passing the event name and listener function.

    Multiple listeners may be bound by passing in a CallbackMap, mapping event names to listener functions.

    Example:

    // Bind a single listener to the 'foo' event
    stream.on('foo', function(arg1, arg2) {
        console.log("Called for 'foo' event", arg1, arg2);
    });
    

    Example:

    // Bind multiple listeners
    stream.on({
        foo : function() { ... },
        bar : function() { ... },
        baz : function() { ... }
    });
    

    It is possible to bind multiple listeners to the same event. In this case, the listeners will be called in the order they were bound.

    Parameters

    • events: string | CallbackMap

      the event name or CallbackMap mapping event names to listeners

    • Optional listener: StreamCallback

      the listener to bind to the event, if passed as string. This argument is ignored if the first argument is a CallbackMap.

    Returns Stream

    this stream.

onStateChange

  • Add a callback that will be called when the session state changes

    Parameters

    • callback: StreamCallback

      the function to call when the session state changes

    Returns void

onSystemPing

  • onSystemPing(): void
  • System ping handler

    Forwards the call to the activity monitor

    Returns void

Private reconnect

  • Attempt to reconnect after disconnecting

    Parameters

    • opts: OptionsImpl

      the session options

    • token: string

      the token of the session when it was connected

    Returns void

Private replaceConversationSet

  • replaceConversationSet(err: Error): void
  • Replace the conversation set with a new one.

    Parameters

    • err: Error

      the error that caused the message loss

    Returns void

setPrincipal

  • setPrincipal(newPrincipal: string): void
  • Set the principal of the session

    Parameters

    • newPrincipal: string

      the new principal

    Returns void

unlock

  • Unlock a session lock by acquisision

    Parameters

    Returns Promise<boolean>

    a Promise that completes when the lock is released

updateFeatures

  • updateFeatures(): void
  • Updates the session with missing features that may have been loaded asynchronously. This method only has an effect when running the client as a modular client in the browser.

    Returns void

Copyright © 2025 DiffusionData Ltd. All Rights Reserved.