Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDDD27_2019_codabify
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jennifer Lindgren
TDDD27_2019_codabify
Commits
09009204
Commit
09009204
authored
6 years ago
by
Jennifer Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
Backend: Added user rooms to be able to notify about added collaborators.
parent
fc4eb4f1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/bootstrap.sh
+1
-1
1 addition, 1 deletion
backend/bootstrap.sh
backend/db.sqlite
+0
-0
0 additions, 0 deletions
backend/db.sqlite
backend/socketio_helper.py
+64
-30
64 additions, 30 deletions
backend/socketio_helper.py
with
65 additions
and
31 deletions
backend/bootstrap.sh
+
1
−
1
View file @
09009204
#!/bin/bash
source
$(
pipenv
--venv
)
/bin/activate
export
PYTHONPATH
=
.
export
FLASK_APP
=
./app.py
export
SECRET
=
"aSHOwmmH75H5s2Nnfdl23J09Shg"
source
$(
pipenv
--venv
)
/bin/activate
python3 app.py
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/db.sqlite
+
0
−
0
View file @
09009204
No preview for this file type
This diff is collapsed.
Click to expand it.
backend/socketio_helper.py
+
64
−
30
View file @
09009204
...
...
@@ -6,6 +6,54 @@ from flask_socketio import SocketIO, send, emit, join_room, leave_room
socketio
=
SocketIO
(
app
)
## Join user room
@socketio.on
(
'
joinUserRoom
'
)
def
on_join_user_room
(
data
):
data
=
json
.
loads
(
data
)
user_id
=
data
[
'
userId
'
]
room
=
'
user
'
+
str
(
user_id
)
join_room
(
room
)
emit
(
'
joinUserRoom
'
,
{
'
on
'
:
'
joinUserRoom
'
,
'
userId
'
:
user_id
},
room
=
room
)
@socketio.on
(
'
leaveUserRoom
'
)
def
on_leave_user_room
(
data
):
data
=
json
.
loads
(
data
)
user_id
=
data
[
'
userId
'
]
room
=
'
user
'
+
str
(
user_id
)
join_room
(
room
)
emit
(
'
leaveUserRoom
'
,
{
'
on
'
:
'
leaveUserRoom
'
,
'
userId
'
:
user_id
},
room
=
room
)
## Join project room
@socketio.on
(
'
joinProjectRoom
'
)
def
on_join_project_room
(
data
):
data
=
json
.
loads
(
data
)
username
=
data
[
'
username
'
]
project_id
=
data
[
'
projectId
'
]
room
=
'
project
'
+
str
(
project_id
)
join_room
(
room
)
emit
(
'
joinProjectRoom
'
,
{
'
on
'
:
'
joinProjectRoom
'
,
'
username
'
:
username
},
room
=
room
)
@socketio.on
(
'
leaveProjectRoom
'
)
def
on_leave_project_room
(
data
):
data
=
json
.
loads
(
data
)
username
=
data
[
'
username
'
]
project_id
=
data
[
'
projectId
'
]
room
=
'
project
'
+
str
(
project_id
)
leave_room
(
room
)
emit
(
'
leaveProjectRoom
'
,
{
'
on
'
:
'
leaveProjectRoom
'
,
'
username
'
:
username
},
room
=
room
)
## Project handling ##
@socketio.on
(
'
projectCreated
'
)
def
handle_project_created
(
data
):
...
...
@@ -13,7 +61,7 @@ def handle_project_created(data):
emit
(
'
projectCreated
'
,
{
'
on
'
:
'
projectCreated
'
,
'
project
'
:
project
},
broadcast
=
True
)
},
room
=
'
project
'
+
str
(
project
[
'
id
'
])
)
@socketio.on
(
'
projectChanged
'
)
def
handle_project_changed
(
data
):
...
...
@@ -21,7 +69,7 @@ def handle_project_changed(data):
emit
(
'
projectChanged
'
,
{
'
on
'
:
'
projectChanged
'
,
'
project
'
:
project
},
broadcast
=
True
)
},
room
=
'
project
'
+
str
(
project
[
'
id
'
])
)
@socketio.on
(
'
projectDeleted
'
)
def
handle_project_deleted
(
data
):
...
...
@@ -29,7 +77,15 @@ def handle_project_deleted(data):
emit
(
'
projectDeleted
'
,
{
'
on
'
:
'
projectDeleted
'
,
'
projectId
'
:
projectId
},
broadcast
=
True
)
},
room
=
'
project
'
+
str
(
projectId
))
@socketio.on
(
'
collaboratorAdded
'
)
def
handle_collaborator_added
(
data
):
collaborator
=
json
.
loads
(
data
)
emit
(
'
collaboratorAdded
'
,
{
'
on
'
:
'
collaboratorAdded
'
,
'
collaborator
'
:
collaborator
},
room
=
'
user
'
+
str
(
collaborator
[
'
userId
'
]))
@socketio.on
(
'
collaboratorChanged
'
)
def
handle_collaborator_changed
(
data
):
...
...
@@ -37,7 +93,7 @@ def handle_collaborator_changed(data):
emit
(
'
collaboratorChanged
'
,
{
'
on
'
:
'
collaboratorChanged
'
,
'
collaborator
'
:
collaborator
},
broadcast
=
True
)
},
room
=
'
project
'
+
str
(
collaborator
[
'
projectId
'
])
)
## File handling ##
@socketio.on
(
'
fileCreated
'
)
...
...
@@ -46,7 +102,7 @@ def handle_file_created(data):
emit
(
'
fileCreated
'
,
{
'
on
'
:
'
fileCreated
'
,
'
file
'
:
file
},
room
=
file
[
'
projectId
'
])
},
room
=
'
project
'
+
str
(
file
[
'
projectId
'
])
)
@socketio.on
(
'
fileChanged
'
)
def
handle_file_changed
(
data
):
...
...
@@ -54,7 +110,7 @@ def handle_file_changed(data):
emit
(
'
fileChanged
'
,
{
'
on
'
:
'
fileChanged
'
,
'
file
'
:
file
},
room
=
file
[
'
projectId
'
])
},
room
=
'
project
'
+
str
(
file
[
'
projectId
'
])
)
@socketio.on
(
'
fileDeleted
'
)
def
handle_file_deleted
(
data
):
...
...
@@ -62,7 +118,7 @@ def handle_file_deleted(data):
emit
(
'
fileDeleted
'
,
{
'
on
'
:
'
fileDeleted
'
,
'
file
'
:
file
},
room
=
file
[
'
projectId
'
])
},
room
=
'
project
'
+
str
(
file
[
'
projectId
'
])
)
## Chat ##
@socketio.on
(
'
message
'
)
...
...
@@ -86,26 +142,4 @@ def handle_message(data):
'
author
'
:
db
.
user_schema
.
dumps
(
author
),
'
time
'
:
new_message
.
time
,
'
message
'
:
message
},
room
=
projectId
)
@socketio.on
(
'
join
'
)
def
on_join
(
data
):
data
=
json
.
loads
(
data
)
username
=
data
[
'
username
'
]
room
=
data
[
'
projectId
'
]
join_room
(
room
)
emit
(
'
join
'
,
{
'
on
'
:
'
join
'
,
'
username
'
:
username
},
room
=
room
)
@socketio.on
(
'
leave
'
)
def
on_leave
(
data
):
data
=
json
.
loads
(
data
)
username
=
data
[
'
username
'
]
room
=
data
[
'
projectId
'
]
leave_room
(
room
)
emit
(
'
leave
'
,
{
'
on
'
:
'
leave
'
,
'
username
'
:
username
},
room
=
room
)
\ No newline at end of file
},
room
=
'
project
'
+
str
(
projectId
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment