GitXplorerGitXplorer
D

pushbroker

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
22df4af2eba5af0e587194b41cceec4cf447492d

Use httptest, and fix concurrency bug, enforcing extra ACK.

DDeleplace committed 9 years ago
Unverified
a669abe572e456681d39cb8a1886a16a2e0400a2

Comment about TOCTOU.

DDeleplace committed 9 years ago
Unverified
7c618218ce896575e0627b90903d730e1dd4bb54

Fix doc.

DDeleplace committed 9 years ago
Unverified
cf58695d06d1fb550fa35528da5f1dc8e040842f

Automated testing: 1 complete scenario.

DDeleplace committed 9 years ago
Unverified
7dca70d34b93db2b43610dd2fcaf4e5d2b721eef

README documentation.

DDeleplace committed 9 years ago
Unverified
43c29621749d16bd6f0e388c68b4b0e3777acf00

Use RLock/RUnlock instead of Lock/Unlock.

DDeleplace committed 9 years ago

README

The README file for this repository.

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.