Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mpv_sync
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stefan Kraus
mpv_sync
Commits
9e7346b8
Commit
9e7346b8
authored
Nov 29, 2020
by
Simon Rainer
Browse files
Options
Downloads
Patches
Plain Diff
Handle sync_to_me on the server side
parent
f4d1a277
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!2
Handle sync_to_me on the server side
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/server.py
+18
-9
18 additions, 9 deletions
server/server.py
with
18 additions
and
9 deletions
server/server.py
+
18
−
9
View file @
9e7346b8
...
...
@@ -106,9 +106,7 @@ class ClientGroup:
current_clients
=
await
self
.
_filter_valid_clients
()
return
[
c
.
get_playback_time
()
for
c
in
current_clients
if
c
.
get_playback_time
()
>=
1
c
.
get_playback_time
()
for
c
in
current_clients
if
c
.
get_playback_time
()
>=
1
]
async
def
play
(
self
):
...
...
@@ -118,7 +116,6 @@ class ClientGroup:
await
self
.
_send_command
(
PAUSE_REQUEST
)
async
def
sync
(
self
):
await
self
.
_send_command
(
GET_PLAYBACK_TIME_REQUEST
)
await
asyncio
.
sleep
(
1
)
...
...
@@ -130,13 +127,27 @@ class ClientGroup:
set_pb_time_filled_req
[
"
data
"
]
=
min_time
await
self
.
_send_command
(
set_pb_time_filled_req
)
async
def
sendCommandToClients
(
self
,
command
):
async
def
sync_to_me
(
self
,
playback_time
):
set_pb_time_filled_req
=
SET_PLAYBACK_TIME_REQUEST
.
copy
()
set_pb_time_filled_req
[
"
data
"
]
=
playback_time
await
self
.
_send_command
(
set_pb_time_filled_req
)
async
def
sendCommandToClients
(
self
,
parsed
):
command
=
parsed
[
"
command
"
]
if
command
==
"
play
"
:
await
self
.
play
()
elif
command
==
"
pause
"
:
await
self
.
pause
()
elif
command
==
"
sync
"
:
await
self
.
sync
()
elif
command
==
"
sync_to_me
"
:
if
"
playback_time
"
not
in
parsed
:
print
(
f
"
Ignoring sync_to_me command, because playback_time is missing: <
{
parsed
}
>
"
)
return
playback_time
=
parsed
[
"
playback_time
"
]
await
self
.
sync_to_me
(
playback_time
)
elif
command
==
"
show
"
:
await
self
.
show_connected_clients
()
else
:
...
...
@@ -164,8 +175,6 @@ async def console_input():
while
True
:
com
=
await
ainput
(
"
>
"
)
print
(
"
cool, but currently we dont listen on this...
"
)
#await sendCommandToClients(com)
async
def
handle
(
ws
:
websockets
.
WebSocketServerProtocol
,
path
:
str
)
->
None
:
...
...
@@ -199,7 +208,7 @@ async def handle(ws: websockets.WebSocketServerProtocol, path: str) -> None:
f
"
Ignoring message that does not contain a command <
{
message
}
>
"
)
else
:
asyncio
.
create_task
(
clients
.
sendCommandToClients
(
parsed
[
"
command
"
]
))
asyncio
.
create_task
(
clients
.
sendCommandToClients
(
parsed
))
finally
:
await
clients
.
remove_client
(
client
)
...
...
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