// Generated by scripts/generate_relay_protocol.py. Do not edit.

abstract final class RelayProtocol {
  static const int protocolVersion = 2;
  static const int legacyProtocolVersion = 0;

  static const String create = 'create';
  static const String join = 'join';
  static const String broadcast = 'broadcast';
  static const String sendTo = 'sendTo';
  static const String ping = 'ping';
  static const String leave = 'leave';
  static const String endSession = 'endSession';
  static const String created = 'created';
  static const String joined = 'joined';
  static const String peerJoined = 'peerJoined';
  static const String peerLeft = 'peerLeft';
  static const String message = 'message';
  static const String error = 'error';
  static const String pong = 'pong';
  static const String left = 'left';
  static const String ended = 'ended';
  static const String rateLimitedCode = 'rate_limited';
  static const String invalidMessageCode = 'invalid_message';
  static const String roomExistsCode = 'room_exists';
  static const String roomNotFoundCode = 'room_not_found';
  static const String roomFullCode = 'room_full';
  static const String notInRoomCode = 'not_in_room';
  static const String alreadyInRoomCode = 'already_in_room';
  static const String peerIdUnavailableCode = 'peer_id_unavailable';
  static const String protocolMismatchCode = 'protocol_mismatch';

  static const int maxRoomSize = 8;
  static const int maxMessageSize = 65536;
  static const int maxSessionIdLength = 64;
  static const int maxPeerIdLength = 128;

  static final RegExp _idPattern = RegExp(r'^[A-Za-z0-9_-]+$');

  static bool isValidSessionId(String value) =>
      value.isNotEmpty && value.length <= maxSessionIdLength && _idPattern.hasMatch(value);

  static bool isValidPeerId(String value) =>
      value.isNotEmpty && value.length <= maxPeerIdLength && _idPattern.hasMatch(value);
}
