Interface: IDirectChannel
Makaio Framework / bus-core / IDirectChannel
Interface: IDirectChannel
Section titled “Interface: IDirectChannel”Defined in: ../../../packages/bus-core/src/channel/types.ts:13
Encrypted point-to-point communication channel over the bus.
Provides a bus-compatible interface (on, once, emit, request) where all
payloads are encrypted with a shared AES-256-GCM key derived via ECDH.
Observers, middleware, and transport loggers only see opaque { iv, data } payloads.
Channel messages ride the normal bus transport layer unless the caller
explicitly constrains routing via the underlying bus configuration.
Properties
Section titled “Properties”channelId
Section titled “channelId”
readonlychannelId:string
Defined in: ../../../packages/bus-core/src/channel/types.ts:15
Unique channel identifier (used in channel-scoped subject namespaces).
Methods
Section titled “Methods”close()
Section titled “close()”close():
void
Defined in: ../../../packages/bus-core/src/channel/types.ts:78
Close the channel. Notifies peer, rejects pending requests, unsubscribes all handlers, and discards the shared encryption key.
Returns
Section titled “Returns”void
emit()
Section titled “emit()”emit<
Subject>(subject,payload):Promise<void>
Defined in: ../../../packages/bus-core/src/channel/types.ts:44
Fire-and-forget encrypted event to the peer.
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends SubjectDefinition
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition
payload
Section titled “payload”Subject["$meta"]["payload"]
Event payload (will be encrypted before dispatch)
Returns
Section titled “Returns”Promise<void>
on<
Subject>(subject,handler,options?): () =>void
Defined in: ../../../packages/bus-core/src/channel/types.ts:25
Register an event or request handler on this channel. The handler receives decrypted payloads — encryption is transparent.
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends SubjectDefinition
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition (channel or non-channel subjects both accepted)
handler
Section titled “handler”HandlerForSubjectDefinition<Subject>
Handler function matching the subject’s schema
options?
Section titled “options?”Handler options (priority, etc.)
Returns
Section titled “Returns”Unsubscribe function
() => void
once()
Section titled “once()”once<
Subject>(subject,handler): () =>void
Defined in: ../../../packages/bus-core/src/channel/types.ts:37
Register a one-time handler that auto-unsubscribes after first invocation.
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends SubjectDefinition
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition
handler
Section titled “handler”HandlerForSubjectDefinition<Subject>
Handler function
Returns
Section titled “Returns”Unsubscribe function
() => void
request()
Section titled “request()”request<
Subject>(subject,payload,options?):Promise<Subject["$meta"]["payload"]["response"]>
Defined in: ../../../packages/bus-core/src/channel/types.ts:55
Encrypted request-response to the peer.
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends SubjectDefinition
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition (must be a request subject)
payload
Section titled “payload”Subject["$meta"]["payload"]["request"]
Request payload (will be encrypted before dispatch)
options?
Section titled “options?”Request options (timeout, etc.)
timeout?
Section titled “timeout?”number
Returns
Section titled “Returns”Promise<Subject["$meta"]["payload"]["response"]>
Decrypted response
Throws
Section titled “Throws”{ChannelClosedError} If the channel is closed
Throws
Section titled “Throws”{NoHandlerError} If the peer has no handler for this subject
requestOptional()
Section titled “requestOptional()”requestOptional<
Subject>(subject,payload,options?):Promise<OptionalResult<Subject["$meta"]["payload"]["response"]>>
Defined in: ../../../packages/bus-core/src/channel/types.ts:68
Encrypted request-response, returns handled: false instead of throwing NoHandlerError.
Type Parameters
Section titled “Type Parameters”Subject
Section titled “Subject”Subject extends SubjectDefinition
Parameters
Section titled “Parameters”subject
Section titled “subject”Subject
Subject definition (must be a request subject)
payload
Section titled “payload”Subject["$meta"]["payload"]["request"]
Request payload
options?
Section titled “options?”Request options
timeout?
Section titled “timeout?”number
Returns
Section titled “Returns”Promise<OptionalResult<Subject["$meta"]["payload"]["response"]>>
OptionalResult wrapping the response