项目作者: rikulo

项目描述 :
socket.io-dart: Dartlang port of socket.io https://github.com/socketio/socket.io
高级语言: Dart
项目地址: git://github.com/rikulo/socket.io-dart.git
创建时间: 2017-02-23T03:46:16Z
项目社区:https://github.com/rikulo/socket.io-dart

开源协议:MIT License

下载


socket.io-dart

Port of awesome JavaScript Node.js library - Socket.io v2.0.1 - in Dart

Usage

  1. import 'package:socket_io/socket_io.dart';
  2. main() {
  3. var io = new Server();
  4. var nsp = io.of('/some');
  5. nsp.on('connection', (client) {
  6. print('connection /some');
  7. client.on('msg', (data) {
  8. print('data from /some => $data');
  9. client.emit('fromServer', "ok 2");
  10. });
  11. });
  12. io.on('connection', (client) {
  13. print('connection default namespace');
  14. client.on('msg', (data) {
  15. print('data from default => $data');
  16. client.emit('fromServer', "ok");
  17. });
  18. });
  19. io.listen(3000);
  20. }
  1. // JS client
  2. var socket = io('http://localhost:3000');
  3. socket.on('connect', function(){console.log('connect')});
  4. socket.on('event', function(data){console.log(data)});
  5. socket.on('disconnect', function(){console.log('disconnect')});
  6. socket.on('fromServer', function(e){console.log(e)});
  1. // Dart client
  2. import 'package:socket_io_client/socket_io_client.dart' as IO;
  3. IO.Socket socket = IO.io('http://localhost:3000');
  4. socket.on('connect', (_) {
  5. print('connect');
  6. socket.emit('msg', 'test');
  7. });
  8. socket.on('event', (data) => print(data));
  9. socket.on('disconnect', (_) => print('disconnect'));
  10. socket.on('fromServer', (_) => print(_));

Multiplexing support

Same as Socket.IO, this project allows you to create several Namespaces, which will act as separate communication channels but will share the same underlying connection.

Room support

Within each Namespace, you can define arbitrary channels, called Rooms, that sockets can join and leave. You can then broadcast to any given room, reaching every socket that has joined it.

Transports support

Refers to engine.io

  • polling: XHR / JSONP polling transport.
  • websocket: WebSocket transport.

Adapters support

Notes to Contributors

Fork socket.io-dart

If you’d like to contribute back to the core, you can fork this repository and send us a pull request, when it is ready.

If you are new to Git or GitHub, please read this guide first.

Who Uses

  • Quire - a simple, collaborative, multi-level task management tool.
  • KEIKAI - a web spreadsheet for Big Data.

Socket.io Dart Client

Contributors