// Code generated by scripts/generate_relay_protocol.py. DO NOT EDIT.

package main

const (
	relayProtocolVersion       = 2
	legacyRelayProtocolVersion = 0

	relayTypeCreate             = "create"
	relayTypeJoin               = "join"
	relayTypeBroadcast          = "broadcast"
	relayTypeSendTo             = "sendTo"
	relayTypePing               = "ping"
	relayTypeLeave              = "leave"
	relayTypeEndSession         = "endSession"
	relayTypeCreated            = "created"
	relayTypeJoined             = "joined"
	relayTypePeerJoined         = "peerJoined"
	relayTypePeerLeft           = "peerLeft"
	relayTypeMessage            = "message"
	relayTypeError              = "error"
	relayTypePong               = "pong"
	relayTypeLeft               = "left"
	relayTypeEnded              = "ended"
	relayErrorRateLimited       = "rate_limited"
	relayErrorInvalidMessage    = "invalid_message"
	relayErrorRoomExists        = "room_exists"
	relayErrorRoomNotFound      = "room_not_found"
	relayErrorRoomFull          = "room_full"
	relayErrorNotInRoom         = "not_in_room"
	relayErrorAlreadyInRoom     = "already_in_room"
	relayErrorPeerIdUnavailable = "peer_id_unavailable"
	relayErrorProtocolMismatch  = "protocol_mismatch"

	maxRoomSize        = 8
	maxMessageSize     = 65536
	maxSessionIDLength = 64
	maxPeerIDLength    = 128
)

func validRelayID(value string, maxLength int) bool {
	if len(value) == 0 || len(value) > maxLength {
		return false
	}
	for _, ch := range value {
		if (ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z') &&
			(ch < '0' || ch > '9') && ch != '_' && ch != '-' {
			return false
		}
	}
	return true
}
