Refactor draft messaging to unified enum-based protocol
- Replaced scattered message strings with `DraftMessage` `StrEnum` and numeric `DraftPhase` `IntEnum` for clear, centralized definitions. - Added Python→JS constants sync via `scripts/generate_js_constants.py` to ensure backend/frontend parity. - Refactored WebSocket consumers to use `broadcast.*` and `direct.message` handlers with `_dispatch_broadcast` for consistent event delivery. - Enhanced `DraftStateManager` to store `draft_index` and explicitly manage `connected_participants`. - Added colored logging config in settings for improved debugging. - Frontend: split UI into `ParticipantList` and `DraftMoviePool`, extracted message handlers (`handleDraftStatusMessages`, `handleUserIdentifyMessages`), and updated components to use new message/phase enums.
This commit is contained in:
@@ -1,51 +1,48 @@
|
||||
// AUTO-GENERATED. Do not edit by hand.
|
||||
// Run: python scripts/generate_js_constants.py
|
||||
|
||||
|
||||
export const DraftMessage = {
|
||||
// Server to Client
|
||||
INFORM: {
|
||||
PHASE_CHANGE: "inform.phase.change",
|
||||
PHASE: "inform.phase",
|
||||
STATUS: "inform.status",
|
||||
JOIN_USER: "inform.join.user",
|
||||
DRAFT_STATUS: "inform.draft_status"
|
||||
},
|
||||
|
||||
// Client to Server
|
||||
REQUEST: {
|
||||
PHASE_CHANGE: "request.phase.change",
|
||||
INFORM_STATUS: "request.inform.status",
|
||||
JOIN_PARTICIPANT: "request.join.participant",
|
||||
JOIN_ADMIN: "request.join.admin",
|
||||
DETERMINE_DRAFT_ORDER: "request.determine.draft_order",
|
||||
DRAFT_STATUS: "request.draft_status"
|
||||
},
|
||||
|
||||
// Confirmation messages (Server to Client)
|
||||
CONFIRM: {
|
||||
PHASE_CHANGE: "confirm.phase.change",
|
||||
JOIN_PARTICIPANT: "confirm.join.participant",
|
||||
JOIN_ADMIN: "confirm.join.admin",
|
||||
DETERMINE_DRAFT_ORDER: "confirm.determine.draft_order",
|
||||
},
|
||||
|
||||
// Client-side notification (to server)
|
||||
NOTIFY: {
|
||||
JOIN_USER: "notify.join.user",
|
||||
},
|
||||
PARTICIPANT_JOIN_REQUEST: "participant.join.request",
|
||||
PARTICIPANT_JOIN_CONFIRM: "participant.join.confirm",
|
||||
PARTICIPANT_JOIN_REJECT: "participant.join.reject",
|
||||
PARTICIPANT_LEAVE_INFORM: "participant.leave.inform",
|
||||
USER_JOIN_INFORM: "user.join.inform",
|
||||
USER_LEAVE_INFORM: "user.leave.inform",
|
||||
USER_IDENTIFICATION_INFORM: "user.identification.inform",
|
||||
PHASE_CHANGE_INFORM: "phase.change.inform",
|
||||
PHASE_CHANGE_REQUEST: "phase.change.request",
|
||||
PHASE_CHANGE_CONFIRM: "phase.change.confirm",
|
||||
STATUS_SYNC_REQUEST: "status.sync.request",
|
||||
STATUS_SYNC_INFORM: "status.sync.inform",
|
||||
DRAFT_INDEX_ADVANCE_REQUEST: "draft.index.advance.request",
|
||||
DRAFT_INDEX_ADVANCE_CONFIRM: "draft.index.advance.confirm",
|
||||
ORDER_DETERMINE_REQUEST: "order.determine.request",
|
||||
ORDER_DETERMINE_CONFIRM: "order.determine.confirm",
|
||||
BID_START_INFORM: "bid.start.inform",
|
||||
BID_PLACE_REQUEST: "bid.place.request",
|
||||
BID_UPDATE_INFORM: "bid.update.inform",
|
||||
BID_END_INFORM: "bid.end.inform",
|
||||
NOMINATION_SUBMIT_REQUEST: "nomination.submit.request",
|
||||
NOMINATION_CONFIRM: "nomination.submit.confirm",
|
||||
};
|
||||
|
||||
export const DraftPhase = {
|
||||
WAITING: 0,
|
||||
DETERMINE_ORDER: 10,
|
||||
NOMINATION: 20,
|
||||
BIDDING: 30,
|
||||
AWARD: 40,
|
||||
FINALIZE: 50,
|
||||
}
|
||||
WAITING: 10,
|
||||
DETERMINE_ORDER: 20,
|
||||
NOMINATING: 30,
|
||||
BIDDING: 40,
|
||||
AWARDING: 50,
|
||||
FINALIZING: 60,
|
||||
};
|
||||
|
||||
export const DraftPhases = [
|
||||
"waiting",
|
||||
"determine_order",
|
||||
"nomination",
|
||||
"bidding",
|
||||
"award",
|
||||
"finalize",
|
||||
]
|
||||
export const DraftPhaseLabel = {
|
||||
[DraftPhase.WAITING]: "waiting",
|
||||
[DraftPhase.DETERMINE_ORDER]: "determine_order",
|
||||
[DraftPhase.NOMINATING]: "nominating",
|
||||
[DraftPhase.BIDDING]: "bidding",
|
||||
[DraftPhase.AWARDING]: "awarding",
|
||||
[DraftPhase.FINALIZING]: "finalizing",
|
||||
};
|
||||
|
||||
export const DraftPhasesOrdered = [DraftPhase.WAITING, DraftPhase.DETERMINE_ORDER, DraftPhase.NOMINATING, DraftPhase.BIDDING, DraftPhase.AWARDING, DraftPhase.FINALIZING];
|
||||
|
||||
Reference in New Issue
Block a user