home

Multiple Window Data Shared Worker

I'm

This system enables multiple browser windows to share and update spatial data such as position, size, and center coordinates. A SharedWorker serves as a background process, allowing real-time coordination and state synchronization across all connected windows. The architecture is designed for interactive, distributed layouts and multi-window web experiences.

Open New Window

Program Flow

  1. A window is opened and loads the client script (logic.js).
  2. It connects to the SharedWorker and registers its unique ID (via window.name).
  3. Every 500 ms, the window calculates and sends its current metrics:
    • x, y: screen position
    • width, height: window dimensions
    • centerX, centerY: computed midpoint
  4. The SharedWorker stores this data and sends updates to all other windows (except the sender).
  5. Windows can manually request:
    • Their own metrics (getMyMetrics)
    • Other windows' metrics (getOtherMetrics)
  6. The UI reflects incoming updates with visual changes and logs.

Provided Functionality

Worker Code

This code is executed in the SharedWorker context.

Client Code