---
title: "Dispatcher API"
url: https://docs.zeroc.com/ice/3.8/runtime/dispatch/dispatcher-api
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Dispatcher API

This page is written for C++, C#, Java, JavaScript, Python, and Swift.

Parts of this page are for some programming languages only, and name them. For one language's text alone, see [C++](https://docs.zeroc.com/ice/3.8/runtime/dispatch/dispatcher-api/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/runtime/dispatch/dispatcher-api/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/runtime/dispatch/dispatcher-api/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/runtime/dispatch/dispatcher-api/js.md), [Python](https://docs.zeroc.com/ice/3.8/runtime/dispatch/dispatcher-api/python.md), and [Swift](https://docs.zeroc.com/ice/3.8/runtime/dispatch/dispatcher-api/swift.md).

A *dispatcher* accepts an incoming request and returns an outgoing response. Servants, [middleware](https://docs.zeroc.com/ice/3.8/runtime/dispatch/middleware.md) and the [dispatch pipeline](https://docs.zeroc.com/ice/3.8/runtime/dispatch/dispatch-pipeline.md) of an object adapter are dispatchers.

> **C++**
>
> A dispatcher is a class derived from [`Ice::Object`](https://code.zeroc.com/ice/3.8/api/cpp/classIce_1_1Object.html) that overrides [`dispatch`](https://code.zeroc.com/ice/3.8/api/cpp/classIce_1_1Object_a4b1aea7f1d61378388dec49ab812bc11.html#a4b1aea7f1d61378388dec49ab812bc11).

> **C#**
>
> A dispatcher is a class that implements [`Ice.Object`](https://code.zeroc.com/ice/3.8/api/csharp/api/Ice.Object.html) and its [`dispatchAsync`](https://code.zeroc.com/ice/3.8/api/csharp/api/Ice.Object.html#Ice_Object_dispatchAsync_) method.

> **Java**
>
> A dispatcher is a class that implements [`com.zeroc.Ice.Object`](https://code.zeroc.com/ice/3.8/api/java/com.zeroc.ice/com/zeroc/Ice/Object.html) and overrides its [`dispatch`](https://code.zeroc.com/ice/3.8/api/java/com.zeroc.ice/com/zeroc/Ice/Object.html#dispatch(com.zeroc.Ice.IncomingRequest)) method.

> **JavaScript**
>
> A dispatcher is a class derived from [`Ice.Object`](https://code.zeroc.com/ice/3.8/api/javascript/Ice/Object.html) that overrides [`dispatch`](https://code.zeroc.com/ice/3.8/api/javascript/Ice/Object.html#dispatch).

> **Python**
>
> Ice for Python has no dispatcher API: the only dispatchers you can implement are servants.

> **Swift**
>
> A dispatcher is a type that adopts the [`Dispatcher`](https://code.zeroc.com/ice/3.8/api/swift/documentation/ice/dispatcher) protocol and implements its [`dispatch`](https://code.zeroc.com/ice/3.8/api/swift/documentation/ice/dispatcher/dispatch(_:)) method.

> **C++, C#, Java, and JavaScript**
>
> Your implementation of this method handles every request the dispatcher receives, including the requests for `ice_id`, `ice_ids`, `ice_isA` and `ice_ping`: you decide whether and how it handles these four operations. You don't need to override the methods that `Object` provides for them.

## Servants

A *servant* is a dispatcher that handles requests itself, rather than passing them to another dispatcher. A servant usually implements a skeleton that the Slice compiler generates for a Slice interface. The skeleton dispatches each request: it unmarshals the parameters, calls the method you implement for the operation, and marshals the return value and out parameters into the response. It also implements the operations of [Object](https://docs.zeroc.com/ice/3.8/slice/operations-on-object.md): `ice_id`, `ice_ids`, `ice_isA` and `ice_ping`.

> **Swift**
>
> To implement `ice_id`, `ice_ids`, `ice_isA` and `ice_ping` yourself, make your servant adopt the [`Ice.Object`](https://code.zeroc.com/ice/3.8/api/swift/documentation/ice/object) protocol in addition to the skeleton protocol, and implement its four methods. The `dispatch` method of the skeleton then calls your methods.

> **C++, C#, Java, JavaScript, and Swift**
>
> A servant can also implement the dispatch method itself, without a generated skeleton: it reads the parameters from the request's input stream and writes its results to an output stream. [Input and Output Streams](https://docs.zeroc.com/ice/3.8/runtime/input-and-output-streams.md) shows how to read and write Slice types with these streams. You add such a servant to an object adapter like any other servant, in its [active servant map](https://docs.zeroc.com/ice/3.8/runtime/dispatch/active-servant-map.md) or as a [default servant](https://docs.zeroc.com/ice/3.8/runtime/dispatch/default-servants.md).
