Skip to content
Advertisement

Tag: socket.io

Setting Socket.io room variables

I would like to store some information in the socket room variables, but am getting the following error: UnhandledPromiseRejectionWarning: TypeError: Cannot set property ‘host’ of undefined This is my code: If I try to log socket.roomId it would return something like rBAhx0. And when I log io.sockets.adapter.rooms, I get the following: However, when I try to log io.sockets.adapter.rooms[socket.roomId], it returns

Unable to connect to socket – Vanilla JS to node.js

I am trying to work with socket.io, however I am unable to establish a connection between my client (Vanilla HTML/JS) and my server (node.js). Server code: I also have several endpoints and functions that are exposed in the same file, though they didn’t seem relevant (as far as I know), so I didn’t include them here, but can if needed.

socket.io broadcast in a room

I am trying to use socket.io to broadcast only to users of a specific room (in another word, to send to all users in that room except me, the sender). So far, I have tried: None of them work unfortunately. Answer io.of(“/”).to(room_temp).emit(‘transcription’, data); would submit to everyone in the room include the user itself. socket.to(room_temp).emit(‘transcription’, data); would submit to everyone

How to stringify js object, so that multiple double quotes are possible when sending it over Socket.io

Well, i guess the main problem is defined in the title, but some special info is: Im trying to emit events to a socket.io api. For the eventtype part this is working fine, but when using JSON.stringify on the packet body (event data) part (which is supposed to be in this format: “{“msg”:”test”}”), it only returns this invalid String: “{“msg”:”test”}”.

How to display the contents of an array as a list?

I’d like to output the contents of an array as a list: value value value However, it’s currently outputting the array like this: value,value,value What can I change to display the array contents as a vertical list? For context, this is displaying an array that updates by adding/removing items based on connections/disconnections to a server. So, when a user connects,

How to add side effect to creating new record in Strapi by customizing controller?

I am trying to trigger a side effect (send notification, using socket.io) when adding new record in Strapi. The socket setup is OK, successfully emitting from back-end (Strapi API) to front-end. I followed the docs on customizing controllers and the recommendations in this Stack Overflow thread, but didn’t help. Nothing happens when changing the controller – tried to break it

Unable to change camera / stream for WebRTC call

Source: https://github.com/anoek/webrtc-group-chat-example/blob/master/client.html I’m trying to modify this Webrtc example to add the ability of changing camera (Cross-browser support). Normal usage works perfectly, after changing camera, failed in renegotiation. 1) Get a list of devices via navigator.mediaDevices.enumerateDevices() 2) Change local_media_stream after getting new stream 3) Trigger renegotiation function (Copied from line 132 of Source code) I believe that my approaches are

Cannot connect to socket io server

I have bot socket IO client and server running. I want to have client communicate with server. Server initialization Client initialization Socket IO debug output I enabled debug, but socket IO debug output is not very useful anyway: Notice that the listener for connection that I added triggers, but socket IO does nothing. What did not help so far: Removing

How can i export socket.io into other modules in nodejs?

I have socket.io working in app.js but when i am trying to call it from other modules its not creating io.connection not sure ? app.js consumer.js Answer Since app.js is usually kind of the main initialization module in your app, it will typically both initialize the web server and socket.io and will load other things that are needed by the

Advertisement