Skip to content

Cannot store io.to("room") in a variable #3444

@fangzhangmnm

Description

@fangzhangmnm

You want to:

  • report a bug
  • request a feature

Current behaviour

When I store a io.to object to a variable, and call the object, the message was sent to all the clients, not only the clients in the room.

Steps to reproduce (if the current behaviour is a bug)

I store io.to to a variable:

this.broadcaster=io.to(this.internalRoomName);

Then I call the variable again somewhere else:

this.broadcaster.emit("someevent","something")

the server broadcast the event to all the client, not only the clients in the room

Expected behaviour

What I expected:

io.to(this.internalRoomName).emit("someevent","something")

Setup

  • OS: Win10
  • browser: Chrome and Edge
  • socket.io version: v2.1.1

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions