diff --git a/client/src/Sockets.vue b/client/src/Sockets.vue
index d373f09..95e2d6c 100644
--- a/client/src/Sockets.vue
+++ b/client/src/Sockets.vue
@@ -2,7 +2,9 @@
We're connected to the server!
We're not connected yet...
-
Message from server: "{{socketMessage}}"
+
+
Message from server: "{{socketMessage}}"
+
@@ -14,7 +16,7 @@
data() {
return {
isConnected: false,
- socketMessage: 'NO_MESSAGE_YET'
+ socketMessage: null
}
},
@@ -41,14 +43,17 @@
methods: {
pingServer() {
// Send the "pingServer" event to the server.
- this.$socket.emit('pingServer', 'PING!');
- console.log("Ping sent!");
+ if (this.isConnected) {
+ this.$socket.emit('pingServer', 'PING!');
+ console.log("Ping sent!");
+ }
},
logOn() {
this.$socket.onconnect();
},
logOff() {
this.$socket.ondisconnect();
+ this.socketMessage = null;
}
}
}
diff --git a/client/src/components/Game.vue b/client/src/components/Game.vue
new file mode 100644
index 0000000..3e5cae6
--- /dev/null
+++ b/client/src/components/Game.vue
@@ -0,0 +1,19 @@
+
+
+
Game on!
+ {{ msg }}
+
+
+
+
+
+
+
diff --git a/server/ws.py b/server/ws.py
index 4c59aa4..d284789 100644
--- a/server/ws.py
+++ b/server/ws.py
@@ -9,21 +9,21 @@ sio = socketio.AsyncServer(
@sio.event
def connect(sid, environ):
- print("connect ", sid, environ)
+ print("[WS] Connect ", sid, environ)
@sio.event
async def chat_message(sid, data):
- print("message ", data)
+ print("[WS] Message ", data)
await sio.emit('reply', room=sid)
@sio.on("pingServer")
async def ping_server(sid, data):
- print("Ping received:", data)
+ print("[WS] Ping received:", data)
await sio.emit('messageChannel', "PONG")
@sio.event
def disconnect(sid):
- print('disconnect ', sid)
+ print('[WS] Disconnect ', sid)