We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import 'package:socket_io/socket_io.dart'; import 'package:socket_io_client/socket_io_client.dart' as IO;
main() {
IO.Socket socket = IO.io('http://localhost:8000'); socket.on('connect', (_) { print('connect'); socket.emit('msg', 'test'); }); socket.on('event', (data) => print(data)); socket.on('disconnect', (_) => print('disconnect')); socket.on('fromServer', (_) => print(_));
}
//node js server const io = require("socket.io"), server = io.listen(8000);
let sequenceNumberByClient = new Map();
server.on("connection", socket => { console.info(Client connected [id=${socket.id}]);
Client connected [id=${socket.id}]
sequenceNumberByClient.set(socket, 1);
socket.on("disconnect", () => { sequenceNumberByClient.delete(socket); console.info(Client gone [id=${socket.id}]); }); });
Client gone [id=${socket.id}]
The text was updated successfully, but these errors were encountered:
maybe you need add trasport option when creating socket instance
socket = IO.io('http://localhost:8000', <String, dynamic>{ 'transports': ['websocket'], });
worked for me
Sorry, something went wrong.
No branches or pull requests
import 'package:socket_io/socket_io.dart';
import 'package:socket_io_client/socket_io_client.dart' as IO;
main() {
}
//node js server
const io = require("socket.io"),
server = io.listen(8000);
let sequenceNumberByClient = new Map();
server.on("connection", socket => {
console.info(
Client connected [id=${socket.id}]
);sequenceNumberByClient.set(socket, 1);
socket.on("disconnect", () => {
sequenceNumberByClient.delete(socket);
console.info(
Client gone [id=${socket.id}]
);});
});
The text was updated successfully, but these errors were encountered: