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
bca99d42
Unverified
Commit
bca99d42
authored
Apr 09, 2020
by
PLN (Algolia)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: Indent, phrasing
parent
f6e98fcf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
110 deletions
+93
-110
App.vue
client/src/App.vue
+56
-59
Sockets.vue
client/src/Sockets.vue
+0
-0
HelloWorld.vue
client/src/components/HelloWorld.vue
+26
-49
app.py
server/app.py
+9
-1
ws.py
server/ws.py
+2
-1
No files found.
client/src/App.vue
View file @
bca99d42
<
template
>
<div
id=
"app"
>
<img
alt=
"Vue logo"
src=
"./assets/logo.png"
/>
<HelloWorld
msg=
"Welcome to Menteur!"
/>
<ListenToSockets
/>
</div>
<div
id=
"app"
>
<HelloWorld
msg=
"Salut Menteur !"
/>
<ListenToSockets/>
</div>
</
template
>
<
script
>
import
Vue
from
'vue'
import
Vuex
from
'vuex'
import
'es6-promise/auto'
// Needed for Promise polyfill
import
Vue
from
'vue'
import
Vuex
from
'vuex'
import
'es6-promise/auto'
// Needed for Promise polyfill
import
VueSocketIO
from
'vue-socket.io'
// import Game from "./components/Game";
import
HelloWorld
from
"./components/HelloWorld"
;
import
ListenToSockets
from
"./Sockets"
;
import
VueSocketIO
from
'vue-socket.io'
Vue
.
use
(
Vuex
);
// import Game from "./components/Game";
import
HelloWorld
from
"./components/HelloWorld"
;
import
ListenToSockets
from
"./ListenToSockets"
;
const
store
=
new
Vuex
.
Store
({
state
:
{
count
:
0
},
mutations
:
{
increment
(
state
)
{
state
.
count
++
},
decrement
(
state
)
{
state
.
count
++
}
}
// TODO: Use actions for VueX-SocketIO integration?
// actions: {
// "
<
ACTION_PREFIX
><
EVENT_NAME
>
"() {
// // do something
// }
// }
});
Vue
.
use
(
Vuex
);
const
store
=
new
Vuex
.
Store
({
state
:
{
count
:
0
},
mutations
:
{
increment
(
state
)
{
state
.
count
++
},
decrement
(
state
)
{
state
.
count
++
}
}
// TODO: Use actions for VueX-SocketIO integration?
// actions: {
// "
<
ACTION_PREFIX
><
EVENT_NAME
>
"() {
// // do something
// }
// }
});
Vue.use(new VueSocketIO({
debug: true,
connection: 'http://localhost:9042',
vuex: {
store,
actionPrefix: 'SOCKET_',
mutationPrefix: 'SOCKET_'
},
options: {path: "
/
socket
.
io
/
"} //Optional options
}));
Vue.use(new VueSocketIO({
debug: true,
connection: 'http://localhost:9042',
vuex: {
store,
actionPrefix: 'SOCKET_',
mutationPrefix: 'SOCKET_'
},
options: { path: "
/
socket
.
io
/
" } //Optional options
}));
export default {
name: "
App
",
components: {
HelloWorld,
ListenToSockets
}
};
export default {
name: "
App
",
components: {
HelloWorld,
ListenToSockets
}
};
</
script
>
<
style
>
#app
{
font-family
:
Avenir
,
Helvetica
,
Arial
,
sans-serif
;
-webkit-font-smoothing
:
antialiased
;
-moz-osx-font-smoothing
:
grayscale
;
text-align
:
center
;
color
:
#2c3e50
;
margin-top
:
60px
;
}
#app
{
font-family
:
Avenir
,
Helvetica
,
Arial
,
sans-serif
;
-webkit-font-smoothing
:
antialiased
;
-moz-osx-font-smoothing
:
grayscale
;
text-align
:
center
;
color
:
#2c3e50
;
margin-top
:
60px
;
}
</
style
>
client/src/
ListenTo
Sockets.vue
→
client/src/Sockets.vue
View file @
bca99d42
File moved
client/src/components/HelloWorld.vue
View file @
bca99d42
<
template
>
<div
class=
"hello"
>
<h1>
Hello Vue!
{{
msg
}}
</h1>
<p>
For a guide and recipes on how to configure / customize this project,
<br
/>
check out the
<a
href=
"https://cli.vuejs.org"
target=
"_blank"
rel=
"noopener"
>
vue-cli documentation
</a
>
.
</p>
<h3>
Installed CLI Plugins
</h3>
<ul>
<li>
<a
href=
"https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
target=
"_blank"
rel=
"noopener"
>
babel
</a
>
</li>
<li>
<a
href=
"https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint"
target=
"_blank"
rel=
"noopener"
>
eslint
</a
>
</li>
</ul>
</div>
<div
class=
"hello"
>
<h1>
{{
msg
}}
</h1>
</div>
</
template
>
<
script
>
export
default
{
name
:
"HelloWorld"
,
props
:
{
msg
:
String
}
};
export
default
{
name
:
"HelloWorld"
,
props
:
{
msg
:
String
}
};
</
script
>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<
style
scoped
>
h3
{
margin
:
40px
0
0
;
}
ul
{
list-style-type
:
none
;
padding
:
0
;
}
li
{
display
:
inline-block
;
margin
:
0
10px
;
}
a
{
color
:
#42b983
;
}
h3
{
margin
:
40px
0
0
;
}
ul
{
list-style-type
:
none
;
padding
:
0
;
}
li
{
display
:
inline-block
;
margin
:
0
10px
;
}
a
{
color
:
#42b983
;
}
</
style
>
server/app.py
View file @
bca99d42
...
...
@@ -3,8 +3,8 @@ from http.client import HTTPException
import
socketio
from
fastapi
import
FastAPI
,
APIRouter
from
fastapi.exceptions
import
RequestValidationError
from
starlette.responses
import
PlainTextResponse
from
starlette.exceptions
import
HTTPException
from
starlette.responses
import
PlainTextResponse
from
server.model.data
import
Game
# Game state
...
...
@@ -16,6 +16,14 @@ game = Game()
# Server
app
=
FastAPI
()
router
=
APIRouter
()
#
# app.add_middleware(
# CORSMiddleware,
# allow_origins=["*"],
# allow_credentials=True,
# allow_methods=["*"],
# allow_headers=["*"],
# )
# Create and mount SocketIO app
sio_asgi_app
=
socketio
.
ASGIApp
(
...
...
server/ws.py
View file @
bca99d42
...
...
@@ -3,9 +3,10 @@ import socketio
sio
=
socketio
.
AsyncServer
(
async_mode
=
'asgi'
,
logger
=
True
,
cors_allowed_origins
=
"*"
# FIXME: CSRF Vulnerability
cors_allowed_origins
=
"*"
# FIXME: CSRF Vulnerability
)
@sio.event
def
connect
(
sid
,
environ
):
print
(
"connect "
,
sid
,
environ
)
...
...
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