= WeeChat Relay protocol :author: Sébastien Helleu :email: flashcode@flashtux.org :lang: en :toc2: :toclevels: 3 :max-width: 100% This document is the specification of WeeChat Relay protocol: the protocol used to relay WeeChat data to clients, which are mostly remote interfaces. [[introduction]] == Introduction [[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 [