Giter Club home page Giter Club logo

websockets's Introduction

WebSocket based GPS readings client/server

This project contains a simple WebSocket demonstation application that provides a global socket for all clients as well as namespace specific sockets with rooms within the namespaces.

In the demo application, the websocket server receives readings from GPS devices and publishes them to web clients. The readings are separated into distinct accounts. The clients will attach to a specific account feed using a WebSocket namespace and receive a list of active GPS devices for that account. The user can select any number of devices to subscribe to (join the WebSocket room) get GPS readings from the subscribed devices. The GPS locations are rendered on a Google Map in the web client and will move around as new locations are received. The GPS readings can either be generated by an include simulator or read off an MQ queue using an included queue processor.

  • The client will connect to an account namespace and then subscribe to a specific rooms based for desired device updates. As new readings for that account are received it will update them in a table. Manual readings can also be submitted by the client.

  • The server will receive readings and publish them. Readings are published to the account specific namespaces where each device has a separate room. This allows clients to subscribe to specific devices.

  • The queue processor will pull in readings from a STOMP enabled MQ queue and send them to the server for distribution to the clients.

  • The simulator will generate randmon GPS information for different accounts and device ids and send them to the server for distribution to the clients. The simulator utilizes polygon data for the US states to produce locations within the US.

This demonstration project also utilizes web workers to spawn off two worker threads. One thread to manage the websocket communications and another to calculate marker transitions to give animation to the markers.

Screenshot of demo client

Installation

  1. Clone the git repository

  2. Install the node dependencies via npm install

Usage

  1. Update config.js as necessary.

  2. Start up the websocket server node ws_server.js Optional command line arguments can be given to specify the desired port number and whether to also start up the queue processor or a redis adapter for load balancing.

  3. Determine if you wish to pull readings from a queue, or simulate random readings:

  • To pull from a queue, start up the queue processor node queue_processor.js

  • To use the simulator either starting it up as a node process node simulator.js or by opening a browser to http://localhost:3700/simulator.html. Then press the "Start" button.

  1. Start up some clients by opening browser tabs to http://localhost:3700/

  2. Subscribe each client to an account. Currently the simulator uses account ids 1-10, so enter a value of 1-10 in the account field and press 'Start'.

Message Specifications

Messaged TO the server

  • send : general communication sent to the server from a socket. Includes new title to broadcast to all clients, and subscribe/unsubscribe requests for the socket.
{"title" : "New title",
 "unsubscribe" : ["3000000010", "3000000011", ...],
 "subscribe"   : ["3000000020", "3000000021", ...]}
  • reading : incoming current raw GPS reading for a specific device
{"account":3,"id":"3000000063","latitude":43.78580828403841,"longitude":-107.68932607986248,"speed":"45.8","heading":"143.4"}
  • device : incoming current processed reading data for the device (ex. reverse geocoded GPS)
TBD
  • disconnect : disconnect from the websocket server

  • stopWS : stop the websocket server. Sends 'stop' to all connected sockets

Messages FROM the server

  • deviceList : provides listing of current devices for an account
["3000000010", "3000000011", "3000000012", ... ]
  • reading : provides current raw GPS reading for a specific device
{"account":3,"id":"3000000063","latitude":43.78580828403841,"longitude":-107.68932607986248,"speed":"45.8","heading":"143.4"}
  • device : provides current processed reading data for the device (ex. reverse geocoded GPS)
TBD
  • message : general messages such as title changes
{"title": "this is the title"}

websockets's People

Contributors

pothoven avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.