Exemple #1
0
def handle_leave_channel(channel, subscribe_socket, push_socket, client_id):
  # unsubscribe to events happening on this channel
  channel_id = remove_user_from_channel(g.user, channel)

  subscribe_socket.setsockopt(zmq.UNSUBSCRIBE, channel_id)

  leave_channel_event = {
      "action": "leave_channel",
      "data": {
        "email": g.user["email"],
        "channel": channel,
      },
  }
  # alert channel subscribers to user leaving
  packed_leave_channel = g.msg_packer.pack(leave_channel_event)
  push_socket.send(" ".join([channel_id, packed_leave_channel]))

  self_leave_channel_event = {
      "action": "self_leave_channel",
      "data": {
        "client_id": client_id,
        "channel": channel,
        "channel_id": channel_id,
      },
  }
  packed_self_leave_channel = g.msg_packer.pack(self_leave_channel_event)
  push_socket.send(" ".join([str(g.user["email"]), packed_self_leave_channel]))
Exemple #2
0
def handle_leave_channel(channel, subscribe_socket, push_socket, client_id):
  # unsubscribe to events happening on this channel
  channel_id = remove_user_from_channel(g.user, channel)

  subscribe_socket.setsockopt(zmq.UNSUBSCRIBE, channel_id)

  leave_channel_event = {
      "action": "leave_channel",
      "data": {
        "user": {
          "email": g.user["email"],
          "gravatar": g.user["gravatar"],
          "name": g.user["name"],
          "username": g.user["email"].split("@")[0],
          "status": "active",
        },
        "channel": channel,
      },
  }
  # alert channel subscribers to user leaving
  packed_leave_channel = json.dumps(leave_channel_event)
  push_socket.send(" ".join([channel_id, packed_leave_channel]))

  self_leave_channel_event = {
      "action": "self_leave_channel",
      "data": {
        "client_id": client_id,
        "channel": channel,
        "channel_id": channel_id,
      },
  }
  packed_self_leave_channel = json.dumps(self_leave_channel_event)
  push_socket.send(" ".join([str(g.user["email"]), packed_self_leave_channel]))
Exemple #3
0
def handle_leave_channel(channel, subscribe_socket, push_socket, client_id):
    # unsubscribe to events happening on this channel
    channel_id = remove_user_from_channel(g.user, channel)

    subscribe_socket.setsockopt(zmq.UNSUBSCRIBE, channel_id)

    leave_channel_event = {
        "action": "leave_channel",
        "data": {
            "user": {
                "email": g.user["email"],
                "gravatar": g.user["gravatar"],
                "name": g.user["name"],
                "username": g.user["email"].split("@")[0],
                "status": "active",
            },
            "channel": channel,
        },
    }
    # alert channel subscribers to user leaving
    packed_leave_channel = json.dumps(leave_channel_event)
    push_socket.send(" ".join([channel_id, packed_leave_channel]))

    self_leave_channel_event = {
        "action": "self_leave_channel",
        "data": {
            "client_id": client_id,
            "channel": channel,
            "channel_id": channel_id,
        },
    }
    packed_self_leave_channel = json.dumps(self_leave_channel_event)
    push_socket.send(" ".join(
        [str(g.user["email"]), packed_self_leave_channel]))