= WeeChat Relay protocol :author: Sébastien Helleu :email: flashcode@flashtux.org :lang: en :toc: left :toclevels: 3 :sectnums: :docinfo1: [[introduction]] == Introduction This document is the specification of WeeChat Relay protocol: the protocol used to relay WeeChat data to clients, which are mostly remote interfaces. [[terminology]] === Terminology The following terms are used in this document: * _relay_: this is the WeeChat with relay plugin, which acts as "server" and allows _clients_ to connect * _client_: this is another software, connected to _relay_ via a network connection; in most cases, this _client_ is a remote interface. [[network_diagram]] === Network diagram The _clients_ are connected to _relay_ like shown in this diagram: .... ┌──────────┐ Workstation ┌────────┐ ┌───┤ client 1 │ (Linux, Windows, │ irc │◄──┐ ╔═══════════╤═══════╗ │ └──────────┘ BSD, Mac OS X ...) └────────┘ └──╢ │ ║◄───┘ ┌──────────┐ ...... ║ WeeChat │ Relay ║◄───────┤ client 2 │ Mobile device ┌────────┐ ┌──╢ │ ║◄───┐ └──────────┘ (Android, iPhone ...) │ jabber │◄──┘ ╚═══════════╧═══════╝ │ ...... └────────┘ │ ┌──────────┐ ...... └───┤ client N │ Other devices └──────────┘ └────────────┘ └───────────────────┘╘══════╛└────────────────────────────────┘ network servers ncurses interface relay remote interfaces protocol .... [NOTE] All clients here are clients using _weechat_ protocol in _relay_ plugin. The _relay_ plugin also allows IRC clients, then _relay_ plugin acts as an _IRC proxy_ (not described in this document). [[protocol_generalities]] == Protocol generalities * Connections from _client_ to _relay_ are made using TCP sockets on IP/port used by _relay_ plugin to listen to new connections. * Number of _clients_ is limited by the option _relay.network.max_clients_. * Each _client_ is independent from other clients. * Messages from _client_ to _relay_ are called _commands_, they are sent as text (a string). * Messages from _relay_ to _client_ are called _messages_, they are sent as binary data. [[commands]] == Commands (client → relay) Commands have format: "(id) command arguments\n". Fields are: * _id_: optional message identifier that will be sent in answer from _relay_; it must be enclosed in parentheses, and must not start with an underscore ("_") (ids starting with underscore are reserved for WeeChat _event_ messages) * _command_: a command (see table below) * _arguments_: optional arguments for command (many arguments are separated by spaces). List of available commands (detail in next chapters): [width="80%",cols="^3m,14",options="header"] |=== | Command | Description | init | Initialize connection with _relay_. | hdata | Request a _hdata_. | info | Request an _info_. | infolist | Request an _infolist_. | nicklist | Request a _nicklist_. | input | Send data to a buffer (text or command). | sync | Synchronize buffer(s) (get updates for buffer(s)). | desync | Desynchronize buffer(s) (stop updates for buffer(s)). | quit | Disconnect from _relay_. |=== [[command_init]] === init Initialize connection with _relay_. This must be first command sent to _relay_. If not sent, _relay_ will close connection on first command received, without warning. Syntax: ---- init [