Comments (9)
Came across the same issue. Apparently calling
.connect()
causes all event handlers to get registered/fired twice.Try removing the
connect()
call, the socket should automatically connect.
still fired twice
from socket.io-client-dart.
Came across the same issue. Apparently calling .connect()
causes all event handlers to get registered/fired twice.
Try removing the connect()
call, the socket should automatically connect.
from socket.io-client-dart.
in Flutter i dont really know why log called twice i will wait answer thank you for your attention
from socket.io-client-dart.
You can also add "'autoConnect': false" option to optional parameters list to stop socket from auto-connecting. In that case you will have to call connect() manually.
from socket.io-client-dart.
Still, shouldn't this at least print out a warning to the log or just ignore a second call to connect()?
from socket.io-client-dart.
@bastibense I reopen it, and it looks like the behavior is not the same as JS version.
from socket.io-client-dart.
Came across the same issue. Apparently calling
.connect()
causes all event handlers to get registered/fired twice.
Try removing theconnect()
call, the socket should automatically connect.still fired twice
Hello
Did you manage to solve this?
from socket.io-client-dart.
Facing the same issue flutter...
from socket.io-client-dart.
front end ----
IO.Socket? socket;
@OverRide
void initState() {
super.initState();
// connect();
focusNode.addListener(() {
if (focusNode.hasFocus) {
setState(() {
show = false;
});
}
});
connect();
}
void connect() {
// MessageModel messageModel = MessageModel(sourceId: widget.sourceChat.id.toString(),targetId: );
socket = IO.io("https://studiovity.com/", <String, dynamic>{
"transports": ["websocket"],
// "autoConnect": true,
});
// socket!.connect();
socket!.emit("signin", widget.sourchat.id);
socket!.onConnect((data) {
print("Connected");
socket!.on("message", (msg) {
print(msg);
setMessage("destination", msg["message"]);
_scrollController.animateTo(_scrollController.position.maxScrollExtent,
duration: Duration(milliseconds: 300), curve: Curves.easeOut);
});
});
print(socket!.connected);
}
Backend
const express = require("express");
var http = require("http");
const app = express();
const port = process.env.PORT || 5000;
var server = http.createServer(app);
var io = require("socket.io")(server);
//middlewre
app.use(express.json());
var clients = {};
io.on("connection", (socket) => {
console.log("connetetd");
// accept();
console.log(socket.id, "has joined");
socket.on("signin", (id) => {
console.log(id);
clients[id] = socket;
console.log(clients);
});
socket.on("message", (msg) => {
console.log(msg);
let targetId = msg.targetId;
if (clients[targetId]) clients[targetId].emit("message", msg);
});
});
server.listen(port, "0.0.0.0", () => {
console.log("server started");
});
from socket.io-client-dart.
Related Issues (20)
- Emit event not working HOT 1
- Double connection? HOT 2
- ConnectError: WebSocketException: Connection to 'https://admin.heartlinkdating.com:0/socket.io/?EIO=4&transport=websocket#' was not upgraded to websocket HOT 8
- how do i force use EIO 3? HOT 1
- Empty query map in OptionsBuilder throws RangeError
- unable to connect to the socket server HOT 6
- WebSocketException: Connection to https://URL/socket.io/?EIO=3&transport=websocket# was not upgraded to websocket HOT 4
- Ho to connect to Socket.io server with uWebsocket
- socket.on('meesage') not working HOT 1
- Unhandled Exception: Unsupported operation: invalid payload HOT 6
- "socket.io": "^4.6.1" not able to connect neither its showing any error neither its creating any breakpoint.
- "socket.io": "^4.6.1"
- Always connection timeout on Android HOT 1
- Socket IO Client Event Firing Twice
- Add timeout on emit and emitWithAck HOT 1
- Flutter Web - can not authorized HOT 1
- Mobile data problem HOT 1
- Connection Error: WebSocketException: Connection to 'https://example.com:0/socket.io/?EIO=4&transport=websocket#' was not upgraded to websocket HOT 1
- Socket event outputs incomplete data .
- Duplicate message on the same timestamp
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socket.io-client-dart.