title: Flask SocketIO: Per client settings
body: <p>When multiple clients connect to my socketio flask application, how can I achieve per-client settings?</p>
  <p>What I have:</p>
  <pre><code>@socketio.on('replay-start')
  def replay(message):
      while True:
          if not paused:
              emit('replay', dict(data=f'private replay'))
          socketio.sleep(1)
  </code></pre>
  <p>Now if a client sends a pause event, I want only the clients loop to pause.</p>
  <p>If I implement it like this:</p>
  <pre><code>@socketio.on('replay-pause')
  def replay_pause(message):
      global paused
      paused = True
  </code></pre>
  <p>Of course this pauses all loops, and not just the one of the current client.
  Is there some way to achieve this? Maybe there is some &quot;context object&quot; where I can see the id of the client sending the message?</p>