diff --git a/backend/routes/games/list.coffee b/backend/routes/games/list.coffee
new file mode 100644
index 0000000..48c2634
--- /dev/null
+++ b/backend/routes/games/list.coffee
@@ -0,0 +1,26 @@
+logger = (require 'logging').default '/games/list'
+
+# session storage (volatile data)
+session = (require '../../session')
+
+module.exports =
+ url: '/games/list'
+ method: 'POST'
+ # schema: (require './info.schema')
+
+ handler: (request, reply) ->
+ session.check request.body.session ? ""
+ .then (userid) ->
+ # active session found, get associated user
+ session.getGames()
+ .then (games) ->
+ logger.debug "OK '#{userid}' got games"
+ reply.send
+ success: true
+ games: games
+
+ .catch ->
+ # no session found
+ logger.info "FAIL '#{request.body.session}' session not found"
+ reply.send
+ success: false
diff --git a/backend/server.coffee b/backend/server.coffee
index 90cad70..e2f10d2 100644
--- a/backend/server.coffee
+++ b/backend/server.coffee
@@ -28,6 +28,8 @@ fastify.route (require "./routes/#{route}") for route in [
'decks/modify'
# delete deck
'decks/delete'
+ # list games
+ 'games/list'
]
# request logging
diff --git a/backend/session.coffee b/backend/session.coffee
index a46a85d..9a70a5c 100644
--- a/backend/session.coffee
+++ b/backend/session.coffee
@@ -88,32 +88,50 @@ class FFTCGSESSION
resolve digest
getGames: ->
- # function to return all active gameKeys
- activeGameKeys = (set, cursor) =>
- # start iteration
- set ?= new Set()
- cursor ?= '0'
+ new Promise (resolve) =>
+ # function to return all active gameKeys
+ activeGameKeys = (set, cursor) =>
+ # start iteration
+ set ?= new Set()
+ cursor ?= '0'
- return new Promise (resolve, reject) =>
- # scan "active" gameKey
- @db.sscan (@gameKey 'active'), cursor, 'COUNT', '100', (err, res) ->
+ return new Promise (resolve, reject) =>
+ # scan "active" gameKey
+ @db.sscan (@gameKey 'active'), cursor, 'COUNT', '100', (err, res) ->
+ if err
+ reject null
- # add to results set
- cursor = res[0]
- for key in res[1]
- set.add key
+ # add to results set
+ cursor = res[0]
+ for key in res[1]
+ set.add key
- if cursor == '0'
- # done on cursor = 0
- resolve set
- else
- # recursive call (resolve one step deeper)
- allGames set, cursor
- .then (set) ->
+ if cursor == '0'
+ # done on cursor = 0
resolve set
+ else
+ # recursive call (resolve one step deeper)
+ allGames set, cursor
+ .then (set) ->
+ resolve set
+
+ activeGameKeys()
+ .then (set) =>
+ activeGames = []
+
+ for key in Array.from set
+ activeGames.push new Promise (resolve) =>
+ @db.hget key, 'owner', (err, res) ->
+ if(err)
+ resolve null
+
+ resolve res
+
+ Promise.all activeGames
+ .then (activeGames) ->
+ console.log activeGames
+ resolve activeGames
- activeGameKeys().then (set) ->
- logger.info "game count: #{Array.from(set).length}"
joinGame: (digest, userid) ->
new Promise (resolve, reject) =>
diff --git a/frontend/src/components/GamesList.vue b/frontend/src/components/GamesList.vue
new file mode 100644
index 0000000..09fe69e
--- /dev/null
+++ b/frontend/src/components/GamesList.vue
@@ -0,0 +1,36 @@
+
+
+
+
+
diff --git a/frontend/src/components/HeaderIntern.vue b/frontend/src/components/HeaderIntern.vue
index ddeebce..34c24f6 100644
--- a/frontend/src/components/HeaderIntern.vue
+++ b/frontend/src/components/HeaderIntern.vue
@@ -4,7 +4,9 @@
view_carousel Decks
- play_arrow Play
+
+ play_arrow Play
+
person {{ user.login }}
diff --git a/frontend/src/router.js b/frontend/src/router.js
index a684503..10ec2a2 100644
--- a/frontend/src/router.js
+++ b/frontend/src/router.js
@@ -28,6 +28,12 @@ export default new Router({
component: () =>
import(/* webpackChunkName: "deckcp" */ './views/DeckCP.vue')
},
+ {
+ path: '/games',
+ name: 'games',
+ component: () =>
+ import(/* webpackChunkName: "games" */ './views/Games.vue')
+ },
{
path: '/game',
name: 'game',
diff --git a/frontend/src/views/Games.vue b/frontend/src/views/Games.vue
new file mode 100644
index 0000000..78113de
--- /dev/null
+++ b/frontend/src/views/Games.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
+ Open Tables
+
+
+
+
+
+