Compare commits
4 Commits
c2e834a67a
...
49cebb9f0a
Author | SHA1 | Date | |
---|---|---|---|
49cebb9f0a | |||
c10eca266a | |||
3fcb1fb8f5 | |||
fce7419c55 |
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
dist
|
||||
.env.development
|
20
Dockerfile
Normal file
20
Dockerfile
Normal file
@ -0,0 +1,20 @@
|
||||
FROM node:19.4-alpine AS frontend
|
||||
|
||||
ARG server_url
|
||||
RUN test -n "${server_url}"
|
||||
|
||||
COPY glebby-client /glebby-client
|
||||
WORKDIR /glebby-client
|
||||
RUN npm install
|
||||
ENV VITE_GLEBBY_SERVER_URL=${server_url}
|
||||
RUN npx vite build --outDir static
|
||||
|
||||
FROM python:3.11-alpine
|
||||
|
||||
COPY glebby-server /glebby-server
|
||||
WORKDIR /glebby-server
|
||||
RUN pip install -r requirements.txt
|
||||
RUN pip install gunicorn
|
||||
COPY --from=frontend /glebby-client/static /glebby-server/static
|
||||
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--threads", "100", "glebby:app"]
|
5
TODO.md
Normal file
5
TODO.md
Normal file
@ -0,0 +1,5 @@
|
||||
- [ ] composition api
|
||||
- [ ] quart
|
||||
- [ ] lobby
|
||||
- [ ] actual game logic
|
||||
- [ ] websocket url config
|
@ -11,6 +11,7 @@ export default {
|
||||
Game
|
||||
},
|
||||
data(): { ws: WebSocket, model: any } {
|
||||
console.log(import.meta.env.VITE_GLEBBY_SERVER_URL)
|
||||
return {
|
||||
ws: new WebSocket(import.meta.env.VITE_GLEBBY_SERVER_URL),
|
||||
model: null
|
||||
|
@ -128,7 +128,7 @@ export default defineComponent({
|
||||
<div class="chatbox-scroller">
|
||||
<div class="chatbox-scroller-content">
|
||||
<div v-for="message in chatMessages" class="chatbox-message">
|
||||
<code>{{ model.players.get(message.from)!.name }}#{{ message.from }}:</code> {{ message.message }}
|
||||
<code v-if="model.players.get(message.from)">{{ model.players.get(message.from)!.name }}#{{ message.from }}:</code> {{ message.message }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
1
glebby-server/.gitignore
vendored
1
glebby-server/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
venv
|
||||
__pycache__
|
||||
static
|
||||
|
@ -117,6 +117,8 @@ class GlebbyState:
|
||||
self.next_client_id += 1
|
||||
return client_id
|
||||
|
||||
# TODO: Instead of using clients_lock, synchronize clients throught incoming_messages
|
||||
# Make add_client and remove_client simply push events into the queue
|
||||
def add_client(self, sock):
|
||||
client_id = self._get_next_client_id()
|
||||
self.broadcast(client_id, {'type': 'join'})
|
||||
@ -150,9 +152,14 @@ class GlebbyState:
|
||||
state = GlebbyState()
|
||||
state.start_event_thread()
|
||||
|
||||
app = Flask(__name__)
|
||||
# TODO: Examine Quart (basically an asyncio version of flask)
|
||||
app = Flask(__name__, static_url_path='')
|
||||
sock = Sock(app)
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return app.send_static_file('index.html')
|
||||
|
||||
@sock.route('/glebby')
|
||||
def echo(sock):
|
||||
client_id = state.add_client(sock)
|
||||
|
Loading…
x
Reference in New Issue
Block a user