title: Join_room in flask-socketio, TypeError: 'int' object is not subscriptable
body: <p>I am trying to create a room and get the output on the client side through the <code>emit</code>, but it doesn't seem to work.
  can you please tell me what's wrong with it.</p>
  <p>I think this is the error but I can't figure out what it means:-</p>
  <blockquote>
  <p>participants = ns[room[0]]._fwdm.copy() if room[0] in ns else {}
  TypeError: 'int' object is not subscriptable</p>
  </blockquote>
  <blockquote>
  <p>File &quot;E:\KabirProject\WebsocketDocs\app.py&quot;, line 36, in join_roomm
  emit('room joined', &quot;Heyy I've joined the room&quot;, to = room)</p>
  </blockquote>
  <p>here are my server side codes:-</p>
  <pre><code>from flask import Flask, render_template
  from flask_socketio import SocketIO, send, emit, join_room
  
  app = Flask(__name__)
  app.config['SECRET_KEY'] = 'secret!'
  socketio = SocketIO(app)
  
  client = 0
  
  @app.route('/')
  def welcome():
     return render_template('index.html')
  
  @app.route('/home')
  def home():
     return render_template('home.html')
  
  @socketio.on('connect')
  def connect_handerler(data):
      global client
      client = client +1
      print(f&quot;\n\n {client}\n\n&quot;)
     
  
  @socketio.on('disconnect')
  def disconnect_handeler():
      global client
      client = client -1
      print(f&quot;\n\n {client}\n\n&quot;)
      
  
  @socketio.on('join')
  def join_roomm(data):
      room = data['room']
      join_room(room)
      emit('room joined', &quot;Heyy I've joined the room&quot;, to = room)   //Line 36
  
  
  if __name__ == '__main__':
      socketio.run(app, debug = True)
  </code></pre>
  <p>Here are my client side codes:-</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;title&gt;Index&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  Index
  &lt;button onclick=&quot;room(1)&quot;&gt;
  Room1
  &lt;/button&gt;
      &lt;button onclick=&quot;room(2)&quot;&gt;
  Room2
      &lt;/button&gt;
          
   &lt;button id=&quot;message&quot; onclick=&quot;message()&quot;&gt;Send a message to server&lt;/button&gt;
  &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js&quot; integrity=&quot;sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
  &lt;script &gt;
      var socket = io();
       socket.on('clients count', function(client){
        // console.log(client);
  
       });
       socket.on('message', function(data){
          console.log(data);
       });
  
      function room(id){
          // console.log(id);
          socket.emit('join',{&quot;room&quot;: id});
      };
  
      socket.on('room joined', function(data){
          console.log(data);
      });
  
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>Here's the error that I am getting:-</p>
  <pre><code> self.run()
    File &quot;c:\users\dell\appdata\local\programs\python\python39\lib\threading.py&quot;, line 892, in run
      self._target(*self._args, **self._kwargs)
    File &quot;E:\KabirProject\WebsocketDocs\websocketsenv\lib\site-packages\socketio\server.py&quot;, line 690, in _handle_event_internal
      r = server._trigger_event(data[0], namespace, sid, *data[1:])
    File &quot;E:\KabirProject\WebsocketDocs\websocketsenv\lib\site-packages\socketio\server.py&quot;, line 714, in _trigger_event
      return self.handlers[namespace][event](*args)
    File &quot;E:\KabirProject\WebsocketDocs\websocketsenv\lib\site-packages\flask_socketio\__init__.py&quot;, line 284, in _handler
      return self._handle_event(handler, message, namespace, sid,
    File &quot;E:\KabirProject\WebsocketDocs\websocketsenv\lib\site-packages\flask_socketio\__init__.py&quot;, line 767, in _handle_event
      ret = handler(*args)
    File &quot;E:\KabirProject\WebsocketDocs\app.py&quot;, line 36, in join_roomm
      emit('room joined', &quot;Heyy I've joined the room&quot;, to = room)
    File &quot;E:\KabirProject\WebsocketDocs\websocketsenv\lib\site-packages\flask_socketio\__init__.py&quot;, line 839, in emit
      return socketio.emit(event, *args, namespace=namespace, to=to,
    File &quot;E:\KabirProject\WebsocketDocs\websocketsenv\lib\site-packages\flask_socketio\__init__.py&quot;, line 462, in emit
      self.server.emit(event, *args, namespace=namespace, to=to,
    File &quot;E:\KabirProject\WebsocketDocs\websocketsenv\lib\site-packages\socketio\server.py&quot;, line 294, in emit
      self.manager.emit(event, data, namespace, room=room,
    File &quot;E:\KabirProject\WebsocketDocs\websocketsenv\lib\site-packages\socketio\base_manager.py&quot;, line 161, in emit
      for sid, eio_sid in self.get_participants(namespace, room):
    File &quot;E:\KabirProject\WebsocketDocs\websocketsenv\lib\site-packages\socketio\base_manager.py&quot;, line 45, in get_participants
      participants = ns[room[0]]._fwdm.copy() if room[0] in ns else {}
  TypeError: 'int' object is not subscriptable
  </code></pre>