I am developing a realtime chat in nodejs and react and socket io. In theory the chat is working, but the problem is that the sender’s message only appears on the screen when the recipient sends a message too. ex : I have browser 1 and browser 2. Every time browser 1 sends messages, these messages appear on its screen,
Tag: socket.io
Created an object in my index.js file, how to make it available in a router file?
I have an index.js file where I: initialize my Express app instance include a router.js file that defines a POST endpoint create a Socket.IO object code as follows: At the POST endpoint in router.js, I want to use the Socket.IO object like this: But this gives me the error: How do I make the io object available to this router.post()
If I don’t choose a file and press the send button, I will get a popup but it’ll break any future popups
If I press Send ☞ without choosing a file, it’ll say “No file selected.” in a little Bootstrap warning alert but it seems to break all future alerts like file uploaded or file already exists on disk. If I make an error alert like file already on disk, it’ll work and won’t break future alerts (meaning it won’t stop alerts
How to programmatically reconnect to server when there is no working connection to the server?
Is there a function/method in socket.io to trigger a ping-pong event from the client-side? I want to ensure that before the client emits an event that it has a working connection with the server. For example, when the client goes into standby or sleep mode with the web application open in the background, the socket.io-client still thinks it’s connected. I
How to use document.write() with a file instead of just text?
I am using socket.io to create a party game similar to cards against humanity. I am just wondering how I can keep the players name and score etc without having to send all the data to a new page when new games begin. I was thinking to just change the body of the html but stay on the same page
Why React js receive multiple answer from server with Socket.io?
When emit a event to the websocket server, the server receive the event once and send a response, but the client receive the event multiple time: result expected result received client side: server side : Answer UPDATE: on the client side I got to put the socket.on(‘response,()=>{…}) in the UseEffect of the component and add a socket.off in the return
Socket.io, Broadcast Emit, Seems To Use Only Latest Socket Connected
I’ve been doing a lot of reading on how different people implement socket.io in their multiplayer games so that I can use it in mine. Granted, I’m a noob with the networking layer for this and I desperately need to learn. Code Context: -Using Phaser3 -Multiplayer game -Load all existing players -Broadcast player joined -Update player position <— My issue
Socket.Io how to emit to all members in a room from a socket instance including the sender
How do I emit to all members of a room from a socket instance? I know I can do io.in(‘room’).emit(‘event’, data); if I have access to the IO instance, but in my case I only have access to the socket of the sender, I store the socket of the user in a user object, and pass it around my code
How to stop running async function on node.js from react application?
React app can run node.js function which preparing data and sending information to the database in batches. It takes a lot of time and I would like to add the ability to stop this function right from react app. I tried a lot of things to include in this function including: while loop: added the variable outside the function –
using socket how to broadcast message to specific users who has role_id = 1
Using Socket and node express i want to send a message to all users who has role_id 1 but whenever i broadcast message all users receive it. status has nothing with message. its just updating user status Answer