-
Notifications
You must be signed in to change notification settings - Fork 0
/
protocol.txt
111 lines (96 loc) · 2.16 KB
/
protocol.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
The User needs to send a message to the server, which contains the session id,
id of user id and the quiz id. The sync server checks if the user is the
quiz's owner and that the quiz is active. The session will be saved in the
session list. The Server will inform the User on success. All messages contain
a field "type" which identifies the message.
// Structure of the sessions array
[
<QuizID> = Quiz(<QuizId>,
<SessionString>,
<UserSession>,
<AttendeeList>),
<QuizID> = Quiz(<QuizId>,
<SessionString>,
<UserSession>,
<AttendeeList>),
...
]
// A user starts a new quiz and registers it on the sync server.
User -> Server
{
type: 'start',
user_id: <UserID>,
session_id: <SessionID>,
quiz_id: <QuizID>
}
// After successfully registering a new quiz, the server informs the user.
Server -> User
{
type: 'start',
successful: true
}
// Attendee logs on a quiz.
Attendee -> Server
{
type: 'logon',
quiz_id: <QuizID>,
nickname: <Nickname>
}
// Server informs the attendee that he is logged on.
Server -> Attendee
{
type: 'logon',
successful: true
}
// Server informs User of new users
Server -> User
{
type: 'logon',
nickname: <nickname>
}
User -> Server
{
type: 'question',
quiz_id : <QuizID>,
session_id: <SessionID>
}
// The server informs the user to get the next question.
Server -> Attendee
{
type: 'question'
}
// Attendee sends answer to the server
Attendee -> Server
{
type: 'answer',
answer: <answer a, b, c, d>,
quiz_id : <QuizID>
}
Server -> User
{
type: 'answer',
answer: <answer a, b, c, d>
}
// The user ends the quiz session. This will delete the session
// data on the sync server.
User -> Server
{
type: 'end',
quiz_id: <QuizId>,
session_id: <SessionID>
}
// Inform the attendees, that the quiz has ended.
Server -> Attendee
{
type: 'end'
}
// To inform the User that the Quiz was successfully closed
Server -> User
{
type: 'end'
}
// Will be send to the User if a client unexpectedly loses connection.
Server -> User
{
type: 'disconnect'
}