aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-07-27 19:35:00 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-07-28 16:07:16 +0200
commita6ded4443bfcd5841cf35390a13cc9c2a82bc553 (patch)
treedacb7d37390df05d940f5ada520e0f1eec01baac
parent583101d34bdbe6c90e178c979fd4de2f9c4c2785 (diff)
protocol: Protocol version 2: message replies
-rw-r--r--protocol.md26
1 files changed, 19 insertions, 7 deletions
diff --git a/protocol.md b/protocol.md
index ac8d86a..8c02017 100644
--- a/protocol.md
+++ b/protocol.md
@@ -1,4 +1,4 @@
-# tomsg protocol (version 1)
+# tomsg protocol (version 2)
The underlying transport of the protocol is a plain TCP socket. The individual
messages are all line-based; this means that a single message, both
@@ -56,18 +56,22 @@ A _response_ from the server will be in one of the following forms:
- Response to the client's `history` command; is followed by exactly `<count>`
messages of type `history_message` with the same tag. The messages are
returned in chronological order (oldest first).
-- `<tag> history_message <index:i64> <roomname:word> <user:word> <timestamp:i64> <msgid:i64> <message:string...>`
+- `<tag> history_message <index:i64> <roomname:word> <user:word> <timestamp:i64> <msgid:i64> <replymsgid:i64> <message:string...>`
- Part of the response to the client's `history` command. Index 0 is the
oldest message; index (`<count>` - 1) (from the `history` response) is the
newest message in the fragment requested. Timestamps are microseconds since
- the UNIX epoch. The message id for each message is globally unique for the
- entire server.
+ the UNIX epoch. The reply message id is -1 if the message is a normal
+ message, or nonnegative if it is a reply to the referenced message in the
+ same room.
A command is identified by its name, which can be found in the list below. Its
arguments are zero or more words, except if for the command in question the last
argument is of type `string...` (in which case it may contain spaces and
ranges until the end of the line).
+Note: all messages on the server have an ID that is globally unique on a single
+tomsg server.
+
- `<tag> version <version:word>`
- Indicates that the client wishes to speak the protocol with the specified
version. For the version of the protocol described in this document, see the
@@ -122,14 +126,20 @@ ranges until the end of the line).
Also marks the current session as active.
- Returns `ok` or `error`.
-- `<tag> send <roomname:word> <message:string...>`
+- `<tag> send <roomname:word> <replymsgid:i64> <message:string...>`
- Sends a message to the given room. All room members receive a
`_push message` push message on all their sessions (except the session the
`send` message was sent from).
+ If `<replymsgid>` is -1, this sends a normal message. Otherwise,
+ `<replymsgid>` must be the id of a message in the given room, in which case
+ the sent message is a reply to the indicated earlier message. If
+ `<replymsgid>` is not a message in this room, `error` is returned.
+
Also marks the current session as active.
The returned `number` response contains the message id of the message sent.
+ This number will be non-negative.
- Returns `number` or `error`.
- `<tag> history <roomname:word> <number:i64>`
- Requests the last `<number>` messages in the given room, if the client is a
@@ -179,9 +189,11 @@ are listed below.
(excluding user X) of all rooms user X is a member of receive a `_push
online` push message stating that `<user>` (user X) is now online with
`<numonline>` sessions.
-- `_push message <roomname:word> <user:word> <timestamp:i64> <msgid:i64> <message:string...>`
+- `_push message <roomname:word> <user:word> <timestamp:i64> <msgid:i64> <replymsgid:i64> <message:string...>`
- Sent to all sessions of all members of a room in which a message is
- posted, except the session that sent the message.
+ posted, except the session that sent the message. `<replymsgid>` is -1 if
+ the message is a normal message, and references the replied-to message
+ otherwise.
- `_push invite <roomname:word> <user:word>`
- Sent to all sessions of the invited user after an `invite` command. The
`<user>` parameter indicates who invited you to the given room.