Skip to content

socket.onAnyOutgoing() cannot receive binary when it uses room #4374

@zoeponta

Description

@zoeponta

Describe the bug

I want to use socket.onAnyOutgoing() to calculate bytes of outgoing messages.
However, when I use a room and send a binary message, socket.onAnyOutgoing() cannot receive it.
So, I cannot calculate correctly.
I can reproduce it with the following code.

To Reproduce

Socket.IO server version: 4.5.0

Server

io.on('connection', (socket: Socket) => {
  socket.onAnyOutgoing((event: string, ...args: any[]) => {
    console.log('onAnyOutgoing:', ...args)
  })

  socket.join('test')
  socket.emit('message', 'hoge')                     // -> onAnyOutgoing: hoge
  socket.emit('message', Buffer.from('hoge'))        // -> onAnyOutgoing: <Buffer 68 6f 67 65>
  io.to('test').emit('message', 'hoge')              // -> onAnyOutgoing: hoge
  io.to('test').emit('message', Buffer.from('hoge')) // -> onAnyOutgoing: { _placeholder: true, num: 0 }
})

Expected behavior

socket.onAnyOutgoing() should receive correctly binary message when it uses room.

  io.to('test').emit('message', Buffer.from('hoge')) // -> onAnyOutgoing:  <Buffer 68 6f 67 65>

Platform:

  • OS : Generic

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions