view doc/html/dev/socket-protocol.md @ 512:b8da1d8c2a72

Docs: use ``` as fenced code blocks
author David Demelier <markand@malikania.fr>
date Fri, 20 Oct 2017 11:43:36 +0200
parents a60142be369a
children
line wrap: on
line source

---
header: Irccd socket API
guide: true
---

This guide will help you controlling irccd via sockets.

Currently, irccd supports internet and unix sockets, you need at least one
transport defined in your **irccd.conf**.

# Syntax

Irccd use JSON as protocol for sending and receiving data. A message must ends
with `\r\n\r\n` to be complete, thus it's possible to write JSON messages in
multiple lines.

For example, this buffer will be parsed as two different messages.

<div class="alert alert-success" role="alert">
**Example**: two commands issued

```json
{
  "param1": "value1"
}

{
  "param1": "value1"
}

```
</div>

<div class="alert alert-warning" role="alert">
**Warning:** please note that the `\r\n\r\n`characters are the escape characters of line feed and new line, not the
concatenation of `\` and `r`.
</div>

## Responses

All commands emit a response with the following properties:

  - **command**: (string) the result of the issued command,
  - **status**: (string) **error** or **ok**,
  - **error**: (string) the error message if status is set to **error**.

<div class="alert alert-success" role="alert">
**Example**: command issued with no errors

```json
{
  "command": "server-message",
  "status": "ok"
}
```
</div>

<div class="alert alert-danger" role="alert">
**Example**: command issued with errors

```json
{
  "command": "server-message",
  "status": "error",
  "error": "server xyz not found"
}
```
</div>