Class: Service

rpc. Service

An RPC service as returned by Service#create.

new rpc.Service(rpcImpl, requestDelimited, responseDelimited)

Constructs a new RPC service instance.

Name Type Default Description
rpcImpl RPCImpl

RPC implementation

requestDelimited boolean false optional

Whether requests are length-delimited

responseDelimited boolean false optional

Whether responses are length-delimited

Extends

Members

requestDelimited { boolean }

Whether requests are length-delimited.

responseDelimited { boolean }

Whether responses are length-delimited.

rpcImpl { RPCImpl | null }

RPC implementation. Becomes null once the service is ended.

Methods

inherited emit(evt, args){ this }

Emits an event by calling its listeners with the specified arguments.

Name Type Description
evt string

Event name

args * repeatable

Arguments

Returns:
Type Description
this this

Ends this service and emits the end event.

Name Type Default Description
endedByRPC boolean false optional

Whether the service has been ended by the RPC implementation.

Returns:
Type Description
rpc.Service this

Removes an event listener or any matching listeners if arguments are omitted.

Name Type Description
evt string optional

Event name. Removes all listeners if omitted.

fn EventEmitterListener optional

Listener to remove. Removes all listeners of evt if omitted.

Returns:
Type Description
this this

inherited on(evt, fn, ctx){ this }

Registers an event listener.

Name Type Description
evt string

Event name

fn EventEmitterListener

Listener

ctx * optional

Listener context

Returns:
Type Description
this this

rpcCall(method, requestCtor, responseCtor, request, callback){ undefined }

Calls a service method through rpcImpl.

Name Type Description
method Method | rpc.ServiceMethod.<TReq, TRes>

Reflected or static method

requestCtor Constructor.<TReq>

Request constructor

responseCtor Constructor.<TRes>

Response constructor

request TReq | Properties.<TReq>

Request message or plain object

callback rpc.ServiceMethodCallback.<TRes>

Service callback

Returns:
Type Description
undefined