Last attempt had bad formatting, somehow. In either case,
open the attached copy
and view with a monospace (equal-width) font.
Request for Comments:
3 dvdrw
Proposal
SenatorHitla
Chat Messages
Status of This Memo
This document describes the form, function, and
specifies the technical
details of a compliant chat implementation.
Abstract
Chat is, perhaps, the central feature of
[bitwave.tv]. It is the counterpart
to the stream. It is implemented using a custom
protocol that has been,
historically, subject to change.
Chat provides a mechanism for direct feedback from
authenticated users to a
streamer; or as means of communication between chat
users themselves.
Assuming equal post rates for all users, chat is
primarily a consumption
service -- spending most of its 'time' delivering
messages to a user rather
than receiving messages from that user.
Chat is also relatively time-sensitive: exact chat
message ordering isn't
necessary, though (near) real-time transmission of
messages is.
Chat is also primarily targeted to be used via web
interfaces, limiting the
effective choice of transport protocols and formats.
Table of Contents
1. Definitions
2. Chat Users
2.1 Authentication
2.2 User Data
2.3 Channels and Channel Owners
2.4 Global/Local Visibility
2.5 User Badges
3. Chat Messages
3.1 Incoming Messages
3.1.a Format of Incoming Messages
3.2 Chat Message Visibility
3.3 Chat Message Integrity
3.3.a Emotes
3.4 Client Commands
3.5 Client Rendering
4. Transport and Protocol
1. Definitions
CHAT USER is an authenticated user with authorization
to post chat messages.
CHAT MESSAGE is the unit of user post. It is
associated with a CHAT ROOM.
CHAT ROOM is a named group of users that contains
CHAT MESSAGES.
CHAT CLIENT is the tool users use to access this
service.
CHAT SERVER is the server that provides this service.
2. Chat Users
2.1 Authentication
Since chat is a subservice to the [bitwave.tv]
website, it is thereby
subordinate to its authentication service(s).
Authentication to chat is done via session tokens
that can be requested
using [bitwave.tv] API. Only one token can be
valid per user
simultaneously.
Users that are successfully authenticated to chat
are considered
connected.
Multiple connections using the same token are
allowed.
2.2 User Data
Users have associated with them a username,
avatar, username color and
user tag.
Avatars are passed as URLs to a subdomain of
'bitwave.tv.'.
Username colors are passed in hex code format
compatible with CSS3.
User tags are displayed immediately preceding a
user's username.
Connected users also have a current channel.
2.3 Channels and Channel Owners
Messages from users are sent to channels.
Channels are distinguished
by their name, case-insensitively.
Users whose username is case-insensitively equal
to a channel name are
that channel's owner.
Since usernames are unique, and channel name is
the distinguishing
factor for channels, the mapping from user to the
channel they own is a
bijection.
In other words, the mapping from user to the
channel they own MUST
be bijective.
Arbitrary channels are allowed.
2.4 Global/Local Visibility
Compliant chat clients SHOULD keep track of a
global/local visibility
flag.
This flag represents the user's ability to view
messages sent to
channels other than the one they are in.
With global visibility, they are able to see all
chat messages.
With local visibility, they only see chat
messages sent in their current
channel.
Compliant chat clients SHOULD include the current
state of this flag in
each message they send (see section 3)
2.5 User Badges
A user badge is a string that is displayed
immediately preceding the
user's username.
Rich content MUST be delivered by self-contained
HTML.
3. Chat Messages
Connected users can send chat messages. They are sent
as JSON objects to the
chat server, and have the following fields:
- message: string ; The content of the
message
- channel: string ; The name of the
channel to which the message is
being sent to
- global: boolean ; The flag representing
the user's current
global/local visibility (see:
2.4 and 3.2)
- showBadge: boolean ; Whether or not to
display the user's badge
for this message
3.1 Incoming Messages
Incoming messages are delivered as JSON objects
with the following
fields, in no particular order:
- avatar: string ; URL to the avatar
of the user who sent the message
- badge: string ; User badge (see
2.5)
- userColor: string ; Username color in
CSS3-compatible hex form
- message: string ; Contents of the
message (see 3.1.a)
- timestamp: number ; Unix-epoch
timestamp in milliseconds
- username: string ; Username of the
user who sent the message
- channel: string ; The channel to
which the message was sent
- global: boolean ; (optional)
Global/Local visibility tag (see 2.4)
- type: string ; Reserved
- id: string ; This message's UUID.
Entirely unique.
3.1.a Format of Incoming Messages
Incoming messages are formatted using
self-contained HTML and CSS.
Incoming messages MUSTN'T contain executable code
embedded in the HTML.
Messages may contain <img> tags whose 'src'
attribute MUST be set to a
valid URL with a host that is a subdomain to
'bitwave.tv.'.
3.2 Chat Message Visibility
Compliant clients may choose to (not) display
messages arbitrarily to
the end user.
Compliant chat clients SHOULD provide a mechanism
for maintaining a list
of users whose messages are automatically not
displayed, called an
'ignore list'.
Compliant chat clients SHOULD respect
global/local visibility (see 2.4).
3.3 Chat Message Integrity
Sent messages may have their message contents
edited by the chat server
before being relayed to other users. This is done
to support formatting,
emotes, and prevent malicious behavior.
Compliant chat servers MUST accept, and be able
to format, a subset of
Markdown, including, but not limited to: (1)
headings (2) bold
(3) italics (4) underline (5) superscript (6)
(un)ordered lists
(7) inline code (8) code block.
Compliant chat servers MUST accept, and be able
to format, emotes.
3.3.a Emotes
Emotes are (optionally animated) images embedded
into chat message body
text.
Client-side, emotes have the form:
emote := ':' identifier ':'
identifier := validCharacter |
identifier validCharacter
validCharacter := /[A-z0-9]/
Servers MUST transform emotes into <img>
tags (see 3.1.a) for
identifiers they support. Emotes with identifiers
the server does not
recognize MUST remain unchanged.
3.4 Client Commands
Messages starting with the character '/' with
alphanumeric characters
immediately following it MUSTN'T be sent.
These messages are client commands. The exact
behavior and existence of
each is implementation defined [1], except for
the command: '/whisper'.
3.5 Client Rendering
Messages SHOULD be rendered using the HTML markup
they're delivered in.
Messages that contain a substring separated by
whitespaces of the format
@username
where 'username' is the user's username SHOULD
trigger the playing of a
notification sound, and SHOULD have the matched
substring highlighted.
4. Transport and Protocol
Communication is done via socket.io sockets (see:
https://socket.io/docs/
for more info)
The hostname and URL for the server are
implementation defined [2].
4.1 Initiation and Maintaining a Connection
Upon successful connection, the server MUST issue
a 'connect' event. The
client then MUST reply with a 'new user' event
which will deliver a USER
PROFILE JSON object.
The USER PROFILE object has the following fields:
- token: string ; Session
token used for authentication
- channel: string ; The user's
current channel
- recaptcha: undefined ; Reserved
In case a drop in connection happens, the server
will issue a
'reconnect' event. Compliant clients SHOULD then
download chat messages
via REST API. The endpoint for this is
implementation defined [3].
It MUST be done via the GET method.
This is a compromise between securing delivery of
messages and server
overhead.
In case of error, the server MUST issue an
'error' event that delivers
an implementation defined [4] object.
4.2 Receiving Data
To deliver messages to the client, the server
does so in bulk to save on
network round-trips. Namely, the server MUST
deliver messages using the
'bulkmessage' event.
This event delivers an array of message objects
(see 3.1).
To maintain an updated list of connected users on
the client, the
server SHOULD be able to request the client
download the list again via
REST API.
This is conducive to minimizing unnecessary
requests for this resource,
as the server can request updates only when
updates are necessary.
The endpoint for this is implementation defined
[5]. It MUST be done via
the GET method.
4.3 Sending Messages
Messages MUST be sent from the client via the
'message' event. It sends
a message object defined in section 3.
5. References
[1-5] - More info about this can be found
under the same reference number
and/or reference to specific section in the
implementation
documentation/compliance report.
Vote to APPROVE for both proposals.
--
You received this message because you are subscribed to the Google Groups "RFC Committee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rfccommittee...@bitwave.tv.
To view this discussion on the web visit https://groups.google.com/a/bitwave.tv/d/msgid/rfccommittee/4026b25c-ff27-fcb9-6f55-1583f336d834%40gmail.com.
Vote to APPROVE for both proposals.
To view this discussion on the web visit https://groups.google.com/a/bitwave.tv/d/msgid/rfccommittee/a1f89339-8b77-9df1-d305-9e7cc8472a4a%40bitwave.tv.