This repository has been archived by the owner on Aug 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTODO
62 lines (58 loc) · 3.57 KB
/
TODO
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
TODO: remove dependency in db.clj from dots.field!!!
TODO: on register(or on auth in future) save mapping of playerId to websocket session
TODO: on all calls involving playerId check that sent playerId corresponds with the websocket session
TWO ANON PLAYERS PLAY JOIN A GAME
---------------------------------
1. player 1 opens websocket channel (autobahn)
2. player 1 gets player id from server and stores it as a cookie (rpc, register)
3. player 1 subscribes to allInvites channel (pubsub, allInvites)
4. player 2 opens websocket channel (autobahn)
5. player 2 gets player id from server and stores it as a cookie (rpc, register)
6. player 2 subscribes to allInvites channel (pubsub, allInvites)
7. player 1 creates invite with settings: name "super game", field 20x20, color: red (rpc, createGame)
8. player 1 receives response with new invite id and subscribes to channel invite-id (pubsub, invite-id)
9. player 2 receives a message with new invite from allInvites topic (pubsub, allInvites)
10. player 2 joins invite (subscribe to channel invite-id) (rpc, joinGame; pubsub, invite-id)
11. player 1 receives a message that player 2 joined (pubsub, invite-id)
12. player 2 sets ready state (rpc, playerReady)
13. player 1 receives message that player 2 is ready (pubsub, invite-id)
14. player 1 starts game (rpc, startGame)
15. player 1 and player 2 receive message with game id (pubsub, invite-id),
unsubscribe from invite-id channel (pubsub, invite-id)
and subscribe to game-id channel (pubsub, game-id)
METHOD DESCRIPTIONS:
register: V - working ("http://dots/register" [name?])
create new anon player in db
if string passed as param - set it as name
return his id and name
createGame: V - working ("http://dots/createInvite" [settings JSON object])
game settings passed as json object
create new invite with settings
create new topic with invite-id name ("http://dots/topic/{generated inviteId}")
send invite to allInvites as json object
return invite as json object
joinGame: V ("http://dots/joinInvite" [{"inviteId": ..., "playerId": ...}])
params - invite-id, player-id
finds invite by id, sets player2-id = player-id, changes state to full
sends updated invite as json object to topic invite-id
sends updated invite (only id and state) as json object to topic allInvites (client will remove it from list, because state is full)
returns invite as json object
playerReady: V ("http://dots/playerReady" [{"inviteId": ..., "playerId": ...}])
params - invite-id, player-id
finds invite by id, checks if player is in game, changes state to starting
sends updated invite as json object to topic invite-id
returns invite as json object
startGame: V ("http://dots/startGame" [{"inviteId": ..., "playerId": ...}])
params - invite-id, player-id
finds invite by id, checks if player is in game
create game with params from invite
create topic game-id
changes invite state to closed, sets created game id to invite
sends updated invite as json object to topic invite-id
returns invite as json object
THOUGHTS ON TESTING:
1. Write a websocket client in clojure/java - sucks, need wamp client also, but high level of automation...
2. Use WAMP Testbed - ok to test one method at a time, but not whole scenario
(think about automation configuration? or at least a way to configure "method calls" and call them later quickly :)
3. Write a custom page for scenario that will act as a player, with a couple of buttons and input fields, and a console-like textarea for responses
4. Implement real client in dots-web... - will proceed with this one