Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions api/controllers/api/v1/quiz_socket_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,32 @@ func handleConnectedUser(c *websocket.Conn, qc *quizSocketController, sessionId
response.Action = constants.ActionSendUserData
response.Component = constants.Waiting

users, err := qc.redis.PubSubModel.Client.Get(
qc.redis.PubSubModel.Ctx,
sessionId,
).Result()

if err == nil && users != "" {
var usersData []UserInfo
if err := json.Unmarshal([]byte(users), &usersData); err == nil {

response := QuizSendResponse{
Component: constants.Waiting,
Action: constants.ActionSendUserData,
Data: usersData,
}

err = func() error {
arrangeMu.Lock()
defer arrangeMu.Unlock()
return utils.JSONSuccessWs( c, constants.EventSendInvitationCode, response )
}()
if err != nil {
qc.logger.Error("error while sending initial user data to admin", zap.Error(err))
}
}
}

pubsub := qc.redis.PubSubModel.Client.Subscribe(qc.redis.PubSubModel.Ctx, fmt.Sprintf("%s-%s", constants.ChannelUserJoin, sessionId), fmt.Sprintf("%s-%s", constants.ChannelUserDisconnect, sessionId), constants.EventTerminateQuiz, constants.EventStartQuizByAdmin, constants.StartQuizByAdminNoPlayerFound)
defer func() {
if pubsub != nil {
Expand Down
42 changes: 16 additions & 26 deletions app/pages/admin/arrange/[session_id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const confirmNeeded = reactive({
const currentComponent = ref("Loading");
const adminOperationHandler = ref();
const analysisTab = ref("ranking");
const session_id = route.params.session_id;
const session_id = computed(() => route.params.session_id);
const runningQuizJoinUser = ref(0);
const isPauseQuiz = ref(false);
const quizState = computed(() =>
Expand All @@ -62,33 +62,23 @@ const handleCustomChange = (isFullScreenEvent) => {

// main functions
onMounted(() => {
// core logic
if (process.client) {
try {
if (socketObject) {
adminOperationHandler.value = new AdminOperations(
session_id,
handleQuizEvents,
handleNetworkEvent,
confirmSkip
);
continueAdmin();
} else {
adminOperationHandler.value = new AdminOperations(
session_id,
handleQuizEvents,
handleNetworkEvent,
confirmSkip
);
connectAdmin();
}
} catch (err) {
console.error(err);
toast.info(app.$ReloadRequired);
}
}
if (!process.client) return;

removeAllUsers();
resetUsersSubmittedAnswers();
currentComponent.value = "Loading";

adminOperationHandler.value = new AdminOperations(
session_id.value,
handleQuizEvents,
handleNetworkEvent,
confirmSkip
);

connectAdmin();
});


const handleQuizEvents = async (message) => {
if (message.status == app.$Error) {
return await router.push(
Expand Down
Loading