Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NCEngine Abstract

The main entry point for the NexConn Chat SDK. Provides static methods for initialization, connection, handler registration, and access to functional modules.

example
// Initialize
NCEngine.initialize({ appKey: 'your-app-key' });

// Connect
const result = await NCEngine.connect({ token: 'user-token' });
if (result.isOk) {
console.log('Connected as:', result.data.userId);
}

// Add handlers
NCEngine.addMessageHandler('main', new MessageHandler({
onMessageReceived({ messages }) {
console.log('New messages:', messages.length);
},
}));

Hierarchy

  • NCEngine

Index

Properties

userModule: UserModule = ...

User-related operations module (subscriptions, profiles, friends)

translateModule: TranslateModule = ...

Translation operations module

initialize: ((params: InitParams) => void) = init

Type declaration

    • Initializes the NexConn Chat SDK. Must be called before any other operations.

      example
      NCEngine.initialize({
      appKey: 'your-app-key',
      logLevel: LogLevel.WARN,
      areaCode: AreaCode.SINGAPORE,
      });

      Parameters

      Returns void

Methods

  • Connects to the NexConn server with the provided token.

    example
    const result = await NCEngine.connect({ token: 'user-token' });
    if (result.isOk) {
    console.log('Connected as:', result.data.userId);
    }

    Parameters

    • params: ConnectParams

      Connection parameters including user token

    Returns Promise<NCResult<ConnectResult>>

    A promise resolving to the connection result containing the user ID

  • Returns the current do-not-disturb quiet hours configuration, if any.

    example
    const result = await NCEngine.getNoDisturbTime();
    if (result.isOk) {
    console.log(result.data.startTime, result.data.spanMinutes);
    }

    Returns Promise<NCResult<NoDisturbTimeInfo>>

  • removeNoDisturbTime(): Promise<NCResult<void>>
  • Clears the do-not-disturb quiet hours configuration.

    example
    await NCEngine.removeNoDisturbTime();
    

    Returns Promise<NCResult<void>>

  • disconnect(disablePush?: boolean): Promise<void>
  • Disconnects from the NexConn server.

    example
    await NCEngine.disconnect();
    

    Parameters

    • Optional disablePush: boolean

      If true, disables push notifications after disconnecting

    Returns Promise<void>

    A promise that resolves when disconnected

  • getCurrentUserId(): string
  • Gets the current connected user's ID.

    example
    const userId = NCEngine.getCurrentUserId();
    

    Returns string

    The user ID, or an empty string if not connected

  • Registers a connection status handler.

    example
    NCEngine.addConnectionStatusHandler('main', new ConnectionStatusHandler({
    onConnectionStateChanged({ status }) {
    console.log('Connection status:', status);
    },
    }));

    Parameters

    • identifier: string

      A unique identifier for this handler

    • handler: ConnectionStatusHandler

      The connection status handler instance

    Returns void

  • removeConnectionStatusHandler(identifier: string): void
  • Removes a previously registered connection status handler.

    Parameters

    • identifier: string

      The unique identifier of the handler to remove

    Returns void

  • Gets the current connection status.

    Returns ConnectionStatus

    The current connection status

  • Sets the do-not-disturb quiet hours period.

    example
    await NCEngine.setNoDisturbTime({
    startTime: '22:00:00',
    spanMinutes: 480,
    level: NoDisturbTimeLevel.MUTED,
    });

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Registers a channel event handler.

    Parameters

    • identifier: string

      A unique identifier for this handler

    • handler: ChannelHandler

      The channel handler instance

    Returns void

  • removeChannelHandler(identifier: string): void
  • Removes a previously registered channel event handler.

    Parameters

    • identifier: string

      The unique identifier of the handler to remove

    Returns void

  • Registers a message event handler.

    Parameters

    • identifier: string

      A unique identifier for this handler

    • handler: MessageHandler

      The message handler instance

    Returns void

  • removeMessageHandler(identifier: string): void
  • Removes a previously registered message event handler.

    Parameters

    • identifier: string

      The unique identifier of the handler to remove

    Returns void

  • addUserHandler(identifier: string, handler: UserHandler): void
  • Registers a user event handler.

    Parameters

    • identifier: string

      A unique identifier for this handler

    • handler: UserHandler

      The user handler instance

    Returns void

  • removeUserHandler(identifier: string): void
  • Removes a previously registered user event handler.

    Parameters

    • identifier: string

      The unique identifier of the handler to remove

    Returns void

  • Registers a user settings sync handler.

    Parameters

    • identifier: string

      A unique identifier for this handler

    • handler: UserSettingsHandler

      The user settings handler instance

    Returns void

  • removeUserSettingsHandler(identifier: string): void
  • Removes a previously registered user settings sync handler.

    Parameters

    • identifier: string

      The unique identifier of the handler to remove

    Returns void

  • Registers a translation event handler.

    Parameters

    • identifier: string

      A unique identifier for this handler

    • handler: TranslateHandler

      The translate handler instance

    Returns void

  • removeTranslateHandler(identifier: string): void
  • Removes a previously registered translation event handler.

    Parameters

    • identifier: string

      The unique identifier of the handler to remove

    Returns void

  • Registers an open channel event handler.

    Parameters

    • identifier: string

      A unique identifier for this handler

    • handler: OpenChannelHandler

      The open channel handler instance

    Returns void

  • removeOpenChannelHandler(identifier: string): void
  • Removes a previously registered open channel event handler.

    Parameters

    • identifier: string

      The unique identifier of the handler to remove

    Returns void

  • addTagHandler(identifier: string, handler: TagHandler): void
  • Registers a tag event handler.

    Parameters

    • identifier: string

      A unique identifier for this handler

    • handler: TagHandler

      The tag handler instance

    Returns void

  • Registers a group channel event handler (group operations, applications, membership).

    example
    NCEngine.addGroupChannelHandler('main', new GroupChannelHandler({
    onGroupOperation(event) {
    console.log('Group operation:', event);
    },
    }));

    Parameters

    • identifier: string

      A unique identifier for this handler

    • handler: GroupChannelHandler

      The group channel handler instance

    Returns void

  • removeGroupChannelHandler(identifier: string): void
  • Removes a previously registered group channel event handler.

    example
    NCEngine.removeGroupChannelHandler('main');
    

    Parameters

    • identifier: string

      The unique identifier of the handler to remove

    Returns void

  • removeTagHandler(identifier: string): void
  • Removes a previously registered tag event handler.

    Parameters

    • identifier: string

      The unique identifier of the handler to remove

    Returns void

  • Registers custom message types with the SDK. Must be called after initialization and before receiving messages of these types.

    example
    NCEngine.registerCustomMessages([
    { messageType: 'app:custom', isPersisted: true, isCounted: true },
    { messageType: 'app:card', isPersisted: true, isCounted: false },
    ]);

    Parameters

    Returns void

  • Gets the application settings from the server configuration.

    example
    const result = NCEngine.getAppSettings();
    if (result.isOk) {
    console.log('Speech-to-text enabled:', result.data.isSpeechToTextEnabled);
    }

    Returns NCResult<AppSettings>

    The application settings or an error result

Constructors