Loop/Architecture/Data Channels: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(→‎Text Messages: Extend implementations notes.)
(Restructure for allowing different data types on different channels.)
Line 20: Line 20:
== Format of Data ==
== Format of Data ==


Data sent across the data channel should be encoded in standard JSON format. Implementations should not fail if additional fields are sent within a message.
The format of the data will vary for different channels, according to the requirements for data across that channel.


It is envisioned that all Loop messages for a data channel will have a contentType field specifying the type of message. Hence the message may be ignored if the contentType is not supported. ''It may be necessary in future to add a feature detection capability.''
== "Text" Data Channel ==


Individual data types have their own structures.
Data sent across the "text" data channel should be encoded in standard JSON format.
 
Individual data types shall have their own defined structures, with contentType being the type of message.
 
Notes:
 
* Implementations should ignore messages with an unknown contentType, this is for forward compatibility.
** ''It may be necessary in furture to have a capability detection system.''
* Implementations should not fail if additional fields are sent within an known message content type.


=== Text Messages ===
=== Text Messages ===

Revision as of 13:31, 25 August 2015

Rooms and Direct Calls in Loop contain the opportunity for text chat. Future extensions of Loop functionality include the possibility for sending mouse locations to the peer, and there are other extensions expected as well.

This document defines the structure for the data channel messaging.

Current Data Types

Loop currently supports transfer of:

  • Text messages

Data Channel Names

The naming of a channel refers to the capability within WebRTC Data channels to supply a name for the channel. The Loop data is allocated to channels as follows:

  • "text"
    • Text messages

Format of Data

The format of the data will vary for different channels, according to the requirements for data across that channel.

"Text" Data Channel

Data sent across the "text" data channel should be encoded in standard JSON format.

Individual data types shall have their own defined structures, with contentType being the type of message.

Notes:

  • Implementations should ignore messages with an unknown contentType, this is for forward compatibility.
    • It may be necessary in furture to have a capability detection system.
  • Implementations should not fail if additional fields are sent within an known message content type.

Text Messages

 {
   contentType: "chat-text",
   message: "Hi!",
   sentTimestamp: "2015-08-24T14:00:27.834Z"
 }
  • contentType: Fixed to "chat-text"
  • message: A standard JavaScript string
  • sentTimestamp: An ISO encoded date

Notes for implementations:

  • Implementations shall handle security concerns around not processing embedded HTML.
  • Implementations should handle their own received timestamp, so that messages are displayed in the correct order e.g. in case of clock skew across the two machines.
  • Implementations should handle linkifying URLs when the message is displayed. These shall not affect the transmitted content.