Skip to content
Jonny edited this page Jun 1, 2019 · 15 revisions

Welcome to the LongDistance wiki!

Just some notes to help you get started.

Lifecycle

There are two parts to this application, the client extension and the server. The extension is located in the extension/ subdirectory, and the server is located mainly in server.js, importing some other files from shared/.

Extension

The extension begins with ldn.js. This is the background page of the Chrome extension.

constructor() {
    this.user = new User();
    this.ws = null;
    this.tabListener = new TabListener();
    chrome.runtime.onMessage.addListener((msg, sender, sendResponse) =>
      this._onRuntimeMessage(msg, sender, sendResponse)
    );
    console.log('<LDN> LDN has been started!');
}

Some things about ldn.js:

  • keeps a local variable user which is just a model that I use to hold user data
  • keeps a local ws reference to the websocket client
  • tabListener listens to tab events to inject loader.js into the Netflix watch page (a viewing page)
  • loader.js is a script that injects controller.js into the DOM

Server

The server begins with server.js. A simple WebSocket server, it keeps a map of lobbies and sockets.

Clone this wiki locally