-
Notifications
You must be signed in to change notification settings - Fork 0
Browser Client
The full client (Factory, producers, consumers — including auth, durable subscriptions, ACK, topics, and groups) runs in the browser. A pre-built bundle ships with the package:
The bundle exposes a global window.mq with Factory, Producer, and
Consumer:
<script src="web/client/tyo-mq-client.js"></script>
<script>
const factory = new mq.Factory({
host: 'mq.example.com', port: 17352, protocol: 'https',
auth: { realm: 'acme', role: 'consumer', key: 'acme-psk' }
});
factory.createConsumer('browser-dashboard').then((consumer) => {
consumer.subscribe('weather-station', 'temperature', (data) => {
render(data);
});
});
</script>A pre-constructed mq.factory (no options) is also provided for quick
same-origin experiments. In module bundlers, require('tyo-mq') works like
Node.
npm run browserify # web/web.js → web/client/tyo-mq-client.jsThe stock server.js enables permissive CORS. For an embedded server,
pass socket.io CORS options:
new Server({ cors: { origin: 'https://app.example.com', methods: ['GET', 'POST'] } });Browser clients authenticate exactly like Node clients — token or
realm/role/pre-shared key in the auth option. For multi-tenant web apps,
the consumer pre-shared key model fits well: ship the realm key to your
frontend session, no per-user broker tokens needed
(Roles and Connection Authorization).
The manager UI (Manager Tools) is itself a browser app using this bundle plus the Web Crypto API to sign management commands locally — proof that full signed-command administration works from a page.
- WebSocket transport is negotiated by socket.io; the server's
allowEIO3: true(stock entry point) keeps older browser clients compatible. - Large messages chunk transparently in both directions, same as Node.
tyo-mq · README · Improvement Plan · Clustering Guide · Apache-2.0
Basics
Security
- Authentication and Realms
- Ephemeral Realms
- Roles and Connection Authorization
- Authorization Requests
Delivery
Routing
Operations
Reference