Compare commits

..

No commits in common. "49cebb9f0ae5ce18f85988f2c77d6adab4bc3265" and "c2e834a67aaa77b65fd2b4519d0acd1eb020f796" have entirely different histories.

7 changed files with 2 additions and 39 deletions

View File

@ -1,3 +0,0 @@
node_modules
dist
.env.development

View File

@ -1,20 +0,0 @@
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"]

View File

@ -1,5 +0,0 @@
- [ ] composition api
- [ ] quart
- [ ] lobby
- [ ] actual game logic
- [ ] websocket url config

View File

@ -11,7 +11,6 @@ export default {
Game Game
}, },
data(): { ws: WebSocket, model: any } { data(): { ws: WebSocket, model: any } {
console.log(import.meta.env.VITE_GLEBBY_SERVER_URL)
return { return {
ws: new WebSocket(import.meta.env.VITE_GLEBBY_SERVER_URL), ws: new WebSocket(import.meta.env.VITE_GLEBBY_SERVER_URL),
model: null model: null

View File

@ -128,7 +128,7 @@ export default defineComponent({
<div class="chatbox-scroller"> <div class="chatbox-scroller">
<div class="chatbox-scroller-content"> <div class="chatbox-scroller-content">
<div v-for="message in chatMessages" class="chatbox-message"> <div v-for="message in chatMessages" class="chatbox-message">
<code v-if="model.players.get(message.from)">{{ model.players.get(message.from)!.name }}#{{ message.from }}:</code> {{ message.message }} <code>{{ model.players.get(message.from)!.name }}#{{ message.from }}:</code> {{ message.message }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,3 +1,2 @@
venv venv
__pycache__ __pycache__
static

View File

@ -117,8 +117,6 @@ class GlebbyState:
self.next_client_id += 1 self.next_client_id += 1
return client_id 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): def add_client(self, sock):
client_id = self._get_next_client_id() client_id = self._get_next_client_id()
self.broadcast(client_id, {'type': 'join'}) self.broadcast(client_id, {'type': 'join'})
@ -152,14 +150,9 @@ class GlebbyState:
state = GlebbyState() state = GlebbyState()
state.start_event_thread() state.start_event_thread()
# TODO: Examine Quart (basically an asyncio version of flask) app = Flask(__name__)
app = Flask(__name__, static_url_path='')
sock = Sock(app) sock = Sock(app)
@app.route('/')
def index():
return app.send_static_file('index.html')
@sock.route('/glebby') @sock.route('/glebby')
def echo(sock): def echo(sock):
client_id = state.add_client(sock) client_id = state.add_client(sock)