---
title: "Dispatcher API"
url: https://docs.zeroc.com/ice/3.8/runtime/dispatch/dispatcher-api
language: swift
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

Programming language: Swift. Other languages: [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).

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

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.

## 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/swift.md): `ice_id`, `ice_ids`, `ice_isA` and `ice_ping`.

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.

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/swift.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/swift.md) or as a [default servant](https://docs.zeroc.com/ice/3.8/runtime/dispatch/default-servants/swift.md).
