Skip to main content

dox_socketio 3.0.0-alpha.5 copy "dox_socketio: ^3.0.0-alpha.5" to clipboard
dox_socketio: ^3.0.0-alpha.5 copied to clipboard

Socket.IO v4 server (Engine.IO v4, Socket.IO protocol v5) for the Dox framework and plain dart:io.

dox_socketio #

Socket.IO v4 server for Dart. It works with the Dox framework and with plain dart:io.

pub package license: MIT

Part of Dox, a web backend framework for Dart, like Laravel. Source code: github.com/dartondox/dox.

Install #

dart pub add dox_socketio

Dox 3.x is in alpha (3.0.0-alpha.4). The API can still change before the stable release.

Use it #

import 'package:dox_socketio/dox_socketio.dart';

Future<void> main() async {
  SocketIoServer io = SocketIoServer();
  io.on('connection', onConnection);
  await io.listen(3001);
}

void onConnection(Socket socket) {
  socket.emit('welcome', 'hello');
  socket.join('lobby');
  socket.on('chat', onChat);
}

void onChat(SocketEvent event) {
  event.socket.to('lobby').emit('chat', event.data); // everyone in lobby but me
  event.ack('ok'); // answer the client callback
}

The official clients connect with no changes: socket.io-client (JavaScript v4) and the Dart socket_io_client package. In a Dox app, turn it on with AppConfig(socketIo: SocketIoConfig(enabled: true)). It then runs on the app port.

Features #

  • Engine.IO protocol v4 and Socket.IO protocol v5 (the protocols of Socket.IO v4).
  • Polling and websocket transports, upgrade, heartbeat and CORS.
  • Namespaces (also as classes), middleware, rooms, broadcast, acks and binary data.
  • In-memory adapter, and a Redis adapter for many servers.
  • The Redis adapter uses the message format of @socket.io/redis-adapter.
  • Limits: fetchSockets, socketsJoin and broadcast acks work only on the local server.

Documentation #

License #

MIT. See LICENSE.

0
likes
160
points
0
downloads

Documentation

API reference

Publisher

verified publisherdartondox.dev

Weekly Downloads

Socket.IO v4 server (Engine.IO v4, Socket.IO protocol v5) for the Dox framework and plain dart:io.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

ioredis

More

Packages that depend on dox_socketio