updateRole method

void updateRole(
  1. Map<String, dynamic> data
)

Update the role of the Remote Peer in the Room, this will emit an event updated with the updated role.

Implementation

void updateRole(Map<String, dynamic> data) {
  try {
    if (!joined) {
      throw Exception(
        "❌ Cannot Update Role, You have not joined the room yet",
      );
    }

    if (data['role'] == role) {
      logger.w('🔔 Peer Role is already set to ${data['role']}');
      return;
    }

    if (peerId == null) {
      logger.e(
        '❌ Cannot Update Role, PeerId Not Found (You have not joined the room yet)',
      );
      return;
    }

    socket.publish(Request_Request.updatePeerRole, {
      'peerId': peerId,
      'role': data['role'],
    });
  } catch (error) {
    logger.e('🔔 Error Updating Role $data | error: $error');
  }
}