Skip to main content
Skip table of contents

Dispatcher API

Ice.Object Base Class

For historical reasons, the Dispatcher abstraction does not correspond to a Dispatcher base class in JavaScript. We use instead the base class Ice.Object as the dispatcher base class.

Object is a concrete class that implements the pseudo Slice interface Object:

JS
export class Object {
    dispatch(request) { ... }
}
TYPESCRIPT
declare module "@zeroc/ice" {
    namespace Ice {
        class Object {
            dispatch(request: IncomingRequest):
                OutgoingResponse | PromiseLike<OutgoingResponse>;
        }
    }
}

The implementation of dispatch on Ice.Object dispatches an incoming request to the 4 operations defined on Object: ice_id, ice_ids, ice_isA, and ice_ping. It throws OperationNotExistException for any other operation.

This implementation is immaterial: in practice, a dispatcher is any JavaScript class derived from Ice.Objectthat reimplements dispatch. This dispatcher may (but does not need to) implement the 4 operations defined on Object.

Servants

In JavaScript, a servant is a concrete class that implements the Dispatcher abstraction by itself, without delegating to some other object. In other words, a servant is a “terminal dispatcher”. A servant should generally handle the 4 operations defined on the pseudo-Slice interface Object.

The most common type of JavaScript servants are classes that implement skeleton classes generated by the Slice compiler. These generated skeleton classes reimplement dispatch by:

  • unmarshaling input parameters

  • calling the pure virtual member function whose name matches the operation name carried by the request (you implement this pure virtual function in the servant class)

  • creating a response from the return value and out parameters returned by this function

They also implement or reimplement the 4 operations defined on Object.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.