MCPcopy Create free account
hub / github.com/Syncplay/syncplay / sendState

Method sendState

syncplay/protocols.py:705–737  ·  view source on GitHub ↗
(self, position, paused, doSeek, setBy, forced=False)

Source from the content-addressed store, hash-verified

703 self.sendList()
704
705 def sendState(self, position, paused, doSeek, setBy, forced=False):
706 if self._clientLatencyCalculationArrivalTime:
707 processingTime = time.time() - self._clientLatencyCalculationArrivalTime
708 else:
709 processingTime = 0
710 playstate = {
711 "position": position if position else 0,
712 "paused": paused,
713 "doSeek": doSeek,
714 "setBy": setBy.getName() if setBy else None
715 }
716 ping = {
717 "latencyCalculation": self._pingService.newTimestamp(),
718 "serverRtt": self._pingService.getRtt()
719 }
720 if self._clientLatencyCalculation:
721 ping["clientLatencyCalculation"] = self._clientLatencyCalculation + processingTime
722 self._clientLatencyCalculation = 0
723 state = {
724 "ping": ping,
725 "playstate": playstate,
726 }
727 if forced:
728 self.serverIgnoringOnTheFly += 1
729 if self.serverIgnoringOnTheFly or self.clientIgnoringOnTheFly:
730 state["ignoringOnTheFly"] = {}
731 if self.serverIgnoringOnTheFly:
732 state["ignoringOnTheFly"]["server"] = self.serverIgnoringOnTheFly
733 if self.clientIgnoringOnTheFly:
734 state["ignoringOnTheFly"]["client"] = self.clientIgnoringOnTheFly
735 self.clientIgnoringOnTheFly = 0
736 if self.serverIgnoringOnTheFly == 0 or forced:
737 self.sendMessage({"State": state})
738
739 def _extractStatePlaystateArguments(self, state):
740 position = state["playstate"]["position"] if "position" in state["playstate"] else 0

Callers

nothing calls this directly

Calls 4

newTimestampMethod · 0.80
getRttMethod · 0.80
sendMessageMethod · 0.80
getNameMethod · 0.45

Tested by

no test coverage detected