fix(relay): harden lifecycle and protocol handling
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// Generated by scripts/generate_relay_protocol.py. Do not edit.
|
||||
|
||||
abstract final class RelayProtocol {
|
||||
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 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 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 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);
|
||||
}
|
||||
Reference in New Issue
Block a user