Class: Server

src/server~ Server

new Server(optionsopt)

Constructs a server object that stores request handlers and delegates incoming requests to those handlers
Parameters:
Name Type Attributes Description
options Object <optional>
Options that should be passed to the internal server implementation
Source:

Methods

addProtoService(service, implementation)

Add a proto service to the server, with a corresponding implementation
Parameters:
Name Type Description
service Protobuf.Reflect.Service The proto service descriptor
implementation Object.<String, function()> Map of method names to method implementation for the provided service.
Source:

addService(service, implementation)

Add a service to the server, with a corresponding implementation. If you are generating this from a proto file, you should instead use addProtoService.
Parameters:
Name Type Description
service Object.<String, *> The service descriptor, as module:src/common.getProtobufServiceAttrs returns
implementation Object.<String, function()> Map of method names to method implementation for the provided service.
Source:

bind(port, credsopt)

Binds the server to the given port, with SSL enabled if creds is given
Parameters:
Name Type Attributes Description
port string The port that the server should bind on, in the format "address:port"
creds boolean <optional>
Server credential object to be used for SSL. Pass nothing for an insecure port
Source:

register(name, handler, serialize, deserialize, type) → {boolean}

Registers a handler to handle the named method. Fails if there already is a handler for the given method. Returns true on success
Parameters:
Name Type Description
name string The name of the method that the provided function should handle/respond to.
handler function Function that takes a stream of request values and returns a stream of response values
serialize function Serialization function for responses
deserialize function Deserialization function for requests
type string The streaming type of method that this handles
Source:
Returns:
True if the handler was set. False if a handler was already set for that name.
Type
boolean

shutdown()

Shuts down the server.
Source:

start()

Start the server and begin handling requests
This:
Source: