API reference / @jsprismarine/management-protocol / jsonRpc
jsonRpc
Interfaces
RpcError
Defined in: jsonRpc.ts:24
The error member of a response.
Properties
code
readonlycode:number
Defined in: jsonRpc.ts:25
data?
readonlyoptionaldata?:string
Defined in: jsonRpc.ts:27
message
readonlymessage:string
Defined in: jsonRpc.ts:26
RpcMethod
Defined in: jsonRpc.ts:58
A method the dispatcher can call.
Properties
beforeStart?
readonlyoptionalbeforeStart?:boolean
Defined in: jsonRpc.ts:62
Whether a client may call it before the server has started, as only rpc.discover may.
call
readonlycall: (params) =>unknown
Defined in: jsonRpc.ts:70
Runs the method.
Parameters
params
Readonly<Record<string, unknown>>
The parameter by name, checked against its schema, or nothing.
Returns
unknown
The result, sent as the response's result.
Throws
When the parameter is well-formed but names something the method cannot act on. Any other error becomes an internal error.
param?
readonlyoptionalparam?:RpcParam
Defined in: jsonRpc.ts:60
The parameter, when the method takes one. No method of the protocol takes more.
RpcNotification
Defined in: jsonRpc.ts:36
A notification the server sends: a method name and its parameters, and no id.
Properties
jsonrpc
readonlyjsonrpc:"2.0"
Defined in: jsonRpc.ts:37
method
readonlymethod:string
Defined in: jsonRpc.ts:38
params?
readonlyoptionalparams?: readonlyunknown[]
Defined in: jsonRpc.ts:39
RpcParam
Defined in: jsonRpc.ts:52
One parameter a method declares, as Mojang's document lists it.
Properties
name
readonlyname:string
Defined in: jsonRpc.ts:53
schema
readonlyschema:unknown
Defined in: jsonRpc.ts:54
RpcTable
Defined in: jsonRpc.ts:74
The methods one connection can call, by name, and the components their schemas refer to.
Properties
components
readonlycomponents:Components
Defined in: jsonRpc.ts:76
methods
readonlymethods:ReadonlyMap<string,RpcMethod>
Defined in: jsonRpc.ts:75
onInternalError?
readonlyoptionalonInternalError?: (method,error) =>void
Defined in: jsonRpc.ts:80
Told about an error a method threw that is not an InvalidParams, which the client sees no detail of.
Parameters
method
string
error
unknown
Returns
void
started
readonlystarted: () =>boolean
Defined in: jsonRpc.ts:78
Whether the server has started; before it has, only beforeStart methods are dispatched.
Returns
boolean
Type Aliases
FrameAnswer
FrameAnswer = {
kind:"reply";text:string; } | {kind:"none"; } | {kind:"close"; }
Defined in: jsonRpc.ts:179
What a frame needs in reply.
Union Members
Type Literal
{ kind: "reply"; text: string; }
A frame to send back.
Type Literal
{ kind: "none"; }
Nothing: the frame was a notification, or a stray response.
Type Literal
{ kind: "close"; }
A batch held something that is not a request, which Java answers by closing the connection.
RpcId
RpcId =
string|number|null
Defined in: jsonRpc.ts:21
A request id: what the client sent, echoed back on the response.
RpcResponse
RpcResponse = {
id:RpcId;jsonrpc:"2.0";result:unknown; } | {error:RpcError;id:RpcId;jsonrpc:"2.0"; }
Defined in: jsonRpc.ts:31
A response: a result or an error, for the request with the same id.
Variables
RPC_ERRORS
constRPC_ERRORS:object
Defined in: jsonRpc.ts:43
The five errors JSON-RPC 2.0 defines, by the name its specification gives them.
Type Declaration
internalError
readonlyinternalError:object
internalError.code
readonlycode:-32603=-32603
internalError.message
readonlymessage:"Internal error"='Internal error'
invalidParams
readonlyinvalidParams:object
invalidParams.code
readonlycode:-32602=-32602
invalidParams.message
readonlymessage:"Invalid params"='Invalid params'
invalidRequest
readonlyinvalidRequest:object
invalidRequest.code
readonlycode:-32600=-32600
invalidRequest.message
readonlymessage:"Invalid Request"='Invalid Request'
methodNotFound
readonlymethodNotFound:object
methodNotFound.code
readonlycode:-32601=-32601
methodNotFound.message
readonlymessage:"Method not found"='Method not found'
parseError
readonlyparseError:object
parseError.code
readonlycode:-32700=-32700
parseError.message
readonlymessage:"Parse error"='Parse error'
Functions
answerFrame()
answerFrame(
text,table):Promise<FrameAnswer>
Defined in: jsonRpc.ts:194
Answers one frame: a request, a notification, or a batch of them.
Parameters
text
string
The frame, as the client sent it.
table
The methods the connection can call.
Returns
Promise<FrameAnswer>
What to send back, if anything.
notificationFrame()
notificationFrame(
method,param?):string
Defined in: jsonRpc.ts:218
A notification frame. MSMP sends a notification's parameter as an array of one value, and no params at all for a notification that has none.
Parameters
method
string
param?
unknown
Returns
string