Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Menteur
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PLN
Menteur
Commits
4a774722
Unverified
Commit
4a774722
authored
Apr 09, 2020
by
PLN (Algolia)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: Better logging
parent
bca99d42
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
Sockets.vue
client/src/Sockets.vue
+6
-1
Game.vue
client/src/components/Game.vue
+19
-0
ws.py
server/ws.py
+4
-4
No files found.
client/src/Sockets.vue
View file @
4a774722
...
...
@@ -2,7 +2,9 @@
<div>
<p
v-if=
"isConnected"
>
We're connected to the server!
</p>
<p
v-if=
"!isConnected"
>
We're not connected yet...
</p>
<div
v-if=
"socketMessage != null"
>
<p>
Message from server: "
{{
socketMessage
}}
"
</p>
</div>
<button
@
click=
"pingServer()"
>
Ping Server
</button>
<button
@
click=
"logOn()"
>
LogOn
</button>
<button
@
click=
"logOff()"
>
LogOff
</button>
...
...
@@ -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.
if
(
this
.
isConnected
)
{
this
.
$socket
.
emit
(
'pingServer'
,
'PING!'
);
console
.
log
(
"Ping sent!"
);
}
},
logOn
()
{
this
.
$socket
.
onconnect
();
},
logOff
()
{
this
.
$socket
.
ondisconnect
();
this
.
socketMessage
=
null
;
}
}
}
...
...
client/src/components/Game.vue
0 → 100644
View file @
4a774722
<
template
>
<div
class=
"hello"
>
<h1>
Game on!
</h1>
<h2>
{{
msg
}}
</h2>
<button
@
click=
"increment"
>
+
</button>
<button
@
click=
"decrement"
>
-
</button>
</div>
</
template
>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<
style
scoped
>
h1
{
margin
:
40px
0
0
;
}
a
{
color
:
#42b983
;
}
</
style
>
server/ws.py
View file @
4a774722
...
...
@@ -9,21 +9,21 @@ sio = socketio.AsyncServer(
@sio.event
def
connect
(
sid
,
environ
):
print
(
"
c
onnect "
,
sid
,
environ
)
print
(
"
[WS] C
onnect "
,
sid
,
environ
)
@sio.event
async
def
chat_message
(
sid
,
data
):
print
(
"
m
essage "
,
data
)
print
(
"
[WS] M
essage "
,
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
(
'
d
isconnect '
,
sid
)
print
(
'
[WS] D
isconnect '
,
sid
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment