Skip to main content

RpcInterface

Defined in: src/lib/rpc/types.ts:43

The global RPC interface used by the SWC modules plugin.

Methods

callClient()

Call Signature

callClient\<T\>(eventName: string, ctx: FireAndForgetContext\<T\>): Promise<void>;

Defined in: src/lib/rpc/types.ts:66

Call a method on a client from the server (fire-and-forget mode).

Type Parameters
Type Parameter
T extends unknown[]
Parameters
ParameterTypeDescription
eventNamestringThe RPC event name (ClassName:methodName@moduleId).
ctxFireAndForgetContext<T>The event context with noResponse: true and target source.
Returns

Promise<void>

Promise that resolves immediately with void (no response awaited).

Call Signature

callClient\<T, R\>(eventName: string, ctx: EventContext\<T\>): Promise\<R\>;

Defined in: src/lib/rpc/types.ts:74

Call a method on a client from the server.

Type Parameters
Type Parameter
T extends unknown[]
R
Parameters
ParameterTypeDescription
eventNamestringThe RPC event name (ClassName:methodName@moduleId).
ctxEventContext<T>The event context containing the payload and target source.
Returns

Promise<R>

Promise that resolves with the client's response.


callServer()

Call Signature

callServer\<T\>(eventName: string, ctx: FireAndForgetContext\<T\>): Promise<void>;

Defined in: src/lib/rpc/types.ts:50

Call a method on the server from the client (fire-and-forget mode).

Type Parameters
Type Parameter
T extends unknown[]
Parameters
ParameterTypeDescription
eventNamestringThe RPC event name (ClassName:methodName@moduleId).
ctxFireAndForgetContext<T>The event context with noResponse: true.
Returns

Promise<void>

Promise that resolves immediately with void (no response awaited).

Call Signature

callServer\<T, R\>(eventName: string, ctx: EventContext\<T\>): Promise\<R\>;

Defined in: src/lib/rpc/types.ts:58

Call a method on the server from the client.

Type Parameters
Type Parameter
T extends unknown[]
R
Parameters
ParameterTypeDescription
eventNamestringThe RPC event name (ClassName:methodName@moduleId).
ctxEventContext<T>The event context containing the payload.
Returns

Promise<R>

Promise that resolves with the server's response.


callWeb()

Call Signature

callWeb\<T\>(eventName: string, ctx: FireAndForgetContext\<T\>): Promise<void>;

Defined in: src/lib/rpc/types.ts:82

Call a method on the web/NUI from the client (fire-and-forget mode).

Type Parameters
Type Parameter
T extends unknown[]
Parameters
ParameterTypeDescription
eventNamestringThe RPC event name (ClassName:methodName@moduleId).
ctxFireAndForgetContext<T>The event context with noResponse: true.
Returns

Promise<void>

Promise that resolves immediately with void (no response awaited).

Call Signature

callWeb\<T, R\>(eventName: string, ctx: EventContext\<T\>): Promise\<R\>;

Defined in: src/lib/rpc/types.ts:90

Call a method on the web/NUI from the client.

Type Parameters
Type Parameter
T extends unknown[]
R
Parameters
ParameterTypeDescription
eventNamestringThe RPC event name (ClassName:methodName@moduleId).
ctxEventContext<T>The event context containing the payload.
Returns

Promise<R>

Promise that resolves with the web/NUI's response.


register()

register\<T, R\>(eventName: string, handler: RpcHandler\<T, R\>): void;

Defined in: src/lib/rpc/types.ts:97

Register a handler for incoming RPC calls.

Type Parameters

Type Parameter
T extends unknown[]
R

Parameters

ParameterTypeDescription
eventNamestringThe RPC event name to handle.
handlerRpcHandler<T, R>The bound method to call when the event is received.

Returns

void


unregister()

unregister(eventName: string): void;

Defined in: src/lib/rpc/types.ts:103

Unregister a handler for RPC calls.

Parameters

ParameterTypeDescription
eventNamestringThe RPC event name to unregister.

Returns

void