dwrtc / ch.hsr.dsl.dwrtc.websocket

Package ch.hsr.dsl.dwrtc.websocket

UI layer. Handles sending and receiving messages from the WebSocket connections.

Design Decisions

Message format

The Message format is reused for WebSocket specific messages (WebSocketErrorMessage, WebSocketIdMessage) and application-specific messages (ClientMessage)

Few Components

The WebSocketHandler consists of four main components:

IDs

The WebSocket session IDs, are reused for the user's session ID. The ID is assumed to be unique.

API Doc

When connected to the WebSocket, an implementation can send or receive the following messages (as JSON objects).

Send

Example:

{
	"type": "CustomMessage",
	"recipientSessionId": "ABCDEF",
	"messageBody": "Hi ABCDEF!"
}

Receive

All these incoming message types have to be handled. They are distinguishable by their type field. They are sent as JSON objects.

``

Types

WebSocketErrorMessage

data class WebSocketErrorMessage : Message

Error messages meant for the WebSocket

WebSocketHandler

class WebSocketHandler

Main handler class

WebSocketIdMessage

data class WebSocketIdMessage : Message

New ID message

Properties

IDLE_TIMEOUT_MS

const val IDLE_TIMEOUT_MS: Long

WebSocket session idle timeout in milliseconds.

WEBSOCKET_PATH

const val WEBSOCKET_PATH: String

Path that the WebSocket handler is available on

WEB_SUB_PATH

const val WEB_SUB_PATH: String

Sub path (to the resources directory) of the web site

Functions

main

fun main(args: Array<String>): Unit

Main start point. Fires up the Webserver.