fennec_socket_io_server 0.0.5 copy "fennec_socket_io_server: ^0.0.5" to clipboard
fennec_socket_io_server: ^0.0.5 copied to clipboard

this plugin belongs to Fennec Framework. it can be used to implement a performant realtime connection from server side.

fennec_socket_io_server is dart plugin to implement SOCKET IO for the server side. it belongs to fennec framework pub.dev but it can be used separately.

Installation #

install the plugin from pub.dev

Example with own HTTP Server. #

ServerIO serverIO1 = ServerIO();
serverIO1.on('connection', (client) {
print('connection');
serverIO1.emit('fromServer', 'ok');
});

await serverIO1.listen('0.0.0.0', 3000);

Example with Fennec HTTP Server. #

 Application application = Application();
 ServerIO serverIO = ServerIO();
 application.setPort(8000).setHost(InternetAddress.loopbackIPv4);
 application.get(
     path: '/dynamic_routes/@userId',
     requestHandler: (req, res) {
       serverIO.emit('fromServer', DateTime.now().toIso8601String());
       res.json({'userId': req.pathParams['userId']});
     },
     middlewares: []);

 Router testRouter = Router(routerPath: '/v1/api');
 testRouter.get(
     path: '/simple', requestHandler: TestController().test, middlewares: []);
 testRouter.get(
   path: '/simple1',
   requestHandler: (Request req, Response res) {
     serverIO.emit('message', 'hello fennec');
     res.send('ss');
   },
 );
serverIO.on('connection', (client) {
print('coo');
});
application.useWebSocket(true);
application.addRouter(testRouter);
application.socketIO(socketIOHandler: (context, ws) {
streamController.sink.add(ws);
});
await serverIO.listenToHttpServer(streamController);
await application.runServer();




License #

MIT

12
likes
130
pub points
32%
popularity

Publisher

verified publisherfennecframework.com

this plugin belongs to Fennec Framework. it can be used to implement a performant realtime connection from server side.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

uuid

More

Packages that depend on fennec_socket_io_server