iniquity

A re-imagining of the iconic BBS software.

View on GitHub

Class: Session

lib/session.Session

Session class implements IQOutput interface for use with core Runtime

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

• new Session(socket, mciOptions?)

Parameters

Name Type
socket Socket
mciOptions? MCIProcessorOptions

Defined in

cli/src/lib/session.ts:107

Properties

connectedAt

• connectedAt: Date

Connection timestamp

Defined in

cli/src/lib/session.ts:90


info

• info: SessionInfo

Defined in

cli/src/lib/session.ts:92


nodeNumber

• nodeNumber: number = 0

Node number assigned by the server

Defined in

cli/src/lib/session.ts:84


username

• username: undefined | string = undefined

Username when logged in (set by BBS layer for snack target by user)

Defined in

cli/src/lib/session.ts:87


MOUSE_PREFIX

▪ Static Readonly MOUSE_PREFIX: "\u0000MOUSE:"

Sentinel for mouse events in the queue (followed by “x:y”)

Defined in

cli/src/lib/session.ts:81

Methods

clearInputQueue

▸ clearInputQueue(): void

Clear the pending input queue

Returns

void

Implementation of

IQOutput.clearInputQueue

Defined in

cli/src/lib/session.ts:659


close

▸ close(): void

Close the session

Returns

void

Implementation of

IQOutput.close

Defined in

cli/src/lib/session.ts:679


getClientSuggestsUtf8

▸ getClientSuggestsUtf8(): boolean

Whether the client suggested UTF-8 (iq term handshake or TERM type)

Returns

boolean

Implementation of

IQOutput.getClientSuggestsUtf8

Defined in

cli/src/lib/session.ts:411


getEncoding

▸ getEncoding(): "utf8" | "cp437"

Get terminal encoding preference (set at connect)

Returns

"utf8" | "cp437"

Implementation of

IQOutput.getEncoding

Defined in

cli/src/lib/session.ts:404


getHeight

▸ getHeight(): number

Get terminal height

Returns

number

Implementation of

IQOutput.getHeight

Defined in

cli/src/lib/session.ts:587


getLineCount

▸ getLineCount(): number

Get current line count (for auto-pause)

Returns

number

Implementation of

IQOutput.getLineCount

Defined in

cli/src/lib/session.ts:531


getMCIProcessor

▸ getMCIProcessor(): MCIProcessor

Get the MCI processor instance

Returns

MCIProcessor

Implementation of

IQOutput.getMCIProcessor

Defined in

cli/src/lib/session.ts:456


getNextSnack

▸ getNextSnack(): null | { corner: string ; durationMs: number ; message: string }

Returns

null | { corner: string ; durationMs: number ; message: string }

Implementation of

IQOutput.getNextSnack

Defined in

cli/src/lib/session.ts:668


getPendingActions

▸ getPendingActions(): ControlCodeAction[]

Get pending actions from MCI processing

Returns

ControlCodeAction[]

Implementation of

IQOutput.getPendingActions

Defined in

cli/src/lib/session.ts:440


getWidth

▸ getWidth(): number

Get terminal width

Returns

number

Implementation of

IQOutput.getWidth

Defined in

cli/src/lib/session.ts:580


hasInput

▸ hasInput(): boolean

Check if input is available without blocking

Returns

boolean

Implementation of

IQOutput.hasInput

Defined in

cli/src/lib/session.ts:652


hasPendingActions

▸ hasPendingActions(): boolean

Check if there are pending actions

Returns

boolean

Defined in

cli/src/lib/session.ts:449


incrementLineCount

▸ incrementLineCount(count?): void

Increment line count

Parameters

Name Type Default value
count number 1

Returns

void

Implementation of

IQOutput.incrementLineCount

Defined in

cli/src/lib/session.ts:545


isPauseAborted

▸ isPauseAborted(): boolean

Check if pause was aborted

Returns

boolean

Implementation of

IQOutput.isPauseAborted

Defined in

cli/src/lib/session.ts:552


isPauseEnabled

▸ isPauseEnabled(): boolean

Check if pause is enabled

Returns

boolean

Implementation of

IQOutput.isPauseEnabled

Defined in

cli/src/lib/session.ts:566


processMCI

▸ processMCI(text): string

Process MCI codes in text without writing

Parameters

Name Type
text string

Returns

string

Implementation of

IQOutput.processMCI

Defined in

cli/src/lib/session.ts:470


pushSnack

▸ pushSnack(payload): void

Parameters

Name Type
payload Object
payload.corner string
payload.durationMs number
payload.message string

Returns

void

Implementation of

IQOutput.pushSnack

Defined in

cli/src/lib/session.ts:664


readKey

▸ readKey(): Promise<string>

Read a single key press (returns the character)

Returns

Promise<string>

Implementation of

IQOutput.readKey

Defined in

cli/src/lib/session.ts:521


readKeyNonBlocking

▸ readKeyNonBlocking(): null | string

Non-blocking key read - returns immediately

Returns

null | string

The key pressed, or null if no input available

Implementation of

IQOutput.readKeyNonBlocking

Defined in

cli/src/lib/session.ts:642


readLine

▸ readLine(): Promise<string>

Read a line of input from the user

Returns

Promise<string>

Implementation of

IQOutput.readLine

Defined in

cli/src/lib/session.ts:477


resetLineCount

▸ resetLineCount(): void

Reset line count (after pause)

Returns

void

Implementation of

IQOutput.resetLineCount

Defined in

cli/src/lib/session.ts:538


setCursorStyle

▸ setCursorStyle(style): void

Set cursor style (if supported)

Parameters

Name Type
style string

Returns

void

Defined in

cli/src/lib/session.ts:617


setEmulatedBaudRate

▸ setEmulatedBaudRate(rate): void

Set emulated baud rate (if supported)

Parameters

Name Type
rate string | number

Returns

void

Defined in

cli/src/lib/session.ts:608


setEncoding

▸ setEncoding(encoding): void

Set terminal encoding; updates MCI context for @CHARSET@ etc.

Parameters

Name Type
encoding "utf8" | "cp437"

Returns

void

Implementation of

IQOutput.setEncoding

Defined in

cli/src/lib/session.ts:418


setMCIContext

▸ setMCIContext(ctx): void

Set MCI context

Parameters

Name Type
ctx Partial<MCIContext>

Returns

void

Implementation of

IQOutput.setMCIContext

Defined in

cli/src/lib/session.ts:463


setPauseAborted

▸ setPauseAborted(aborted): void

Set pause aborted state

Parameters

Name Type
aborted boolean

Returns

void

Implementation of

IQOutput.setPauseAborted

Defined in

cli/src/lib/session.ts:559


setPauseEnabled

▸ setPauseEnabled(enabled): void

Enable/disable pause

Parameters

Name Type
enabled boolean

Returns

void

Implementation of

IQOutput.setPauseEnabled

Defined in

cli/src/lib/session.ts:573


setSyncTermFont

▸ setSyncTermFont(fontNameOrAlias, page?): boolean

Set SyncTERM font (if supported)

Parameters

Name Type Default value
fontNameOrAlias string undefined
page number 0

Returns

boolean

Implementation of

IQOutput.setSyncTermFont

Defined in

cli/src/lib/session.ts:594


setTickCallback

▸ setTickCallback(cb): void

Set the callback run every 10ms while waitKey() is active (e.g. processQueue + processSnacks). Used so snacks and events are processed when waiting in popup/pause/choice etc.

Parameters

Name Type
cb () => Promise<void>

Returns

void

Defined in

cli/src/lib/session.ts:514


setUsername

▸ setUsername(handle): void

Parameters

Name Type
handle undefined | string

Returns

void

Implementation of

IQOutput.setUsername

Defined in

cli/src/lib/session.ts:672


supportsFonts

▸ supportsFonts(): boolean

Check if client supports font switching

Returns

boolean

Implementation of

IQOutput.supportsFonts

Defined in

cli/src/lib/session.ts:634


supportsIceColors

▸ supportsIceColors(): boolean

Check if client supports iCE colors

Returns

boolean

Defined in

cli/src/lib/session.ts:627


waitKey

▸ waitKey(): Promise<string>

Wait for any key press (does not echo). While waiting, if a tick callback is set, runs it every 10ms (serialized, no overlap).

Returns

Promise<string>

Implementation of

IQOutput.waitKey

Defined in

cli/src/lib/session.ts:488


write

▸ write(data): void

Write data to socket (converts to UTF-8 when session encoding is utf8)

Parameters

Name Type
data string

Returns

void

Implementation of

IQOutput.write

Defined in

cli/src/lib/session.ts:393


writeMCI

▸ writeMCI(data): void

Write with MCI processing enabled (respects session encoding)

Parameters

Name Type
data string

Returns

void

Implementation of

IQOutput.writeMCI

Defined in

cli/src/lib/session.ts:427