Coder Social home page Coder Social logo

pushbroker's Introduction

pushbroker

Message broker for web browsers

The purpose is to let any peer A send a text message M to any peer B, where A and B may be web browsers.

This implementation uses an intermediate server between A and B : the "Broker".

The Broker is implemented using bi-directional WebSockets: each peer registers itself, then uses a long-lived WebSocket connection to send and receive messages.

Broker

Currently, the peer chooses its own name, acting as peer ID, before the connection. An equivalent strategy would be to have the server assign generated peer IDs to each incoming peer (but then it would be more difficult for a host to have a consistent ID on subsequent connections).

The Broker implementation in Go uses a global map to keep track of all known peers and their open connections. To prevent data races caused by concurrent messages handling, the global map is guarded by a RWMutex, and each map entry (outgoing peer connection) is guarded by a Mutex.

The communication from peer A to the Broker consists in 2 frames: 1 for the target peer name B and 1 for the message M. A simple refactoring would have the 2 pieces of information serialized in a single frame.

Because the server is small and executable, it is implemented in a single source file having a main func, declared in package main. A more fancy project structure would have a custom package name, and an executable command outside the package.

pushbroker's People

Contributors

deleplace avatar ripounet avatar

Watchers

 avatar  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.