First broadcast of filename being playing
This commit is contained in:
parent
8b11382e98
commit
eaaa661099
@ -44,6 +44,11 @@ class SyncClientProtocol(CommandProtocol):
|
|||||||
def handle_connected_ping(self, args):
|
def handle_connected_ping(self, args):
|
||||||
self.send_message('pong', args[0])
|
self.send_message('pong', args[0])
|
||||||
|
|
||||||
|
@arg_count(2)
|
||||||
|
def handle_connected_playing(self, args):
|
||||||
|
who, what = args
|
||||||
|
print '%s plays %s' % (who, what)
|
||||||
|
|
||||||
def send_state(self, counter, paused, position):
|
def send_state(self, counter, paused, position):
|
||||||
self.send_message('state', counter, ('paused' if paused else 'playing'), int(position*1000))
|
self.send_message('state', counter, ('paused' if paused else 'playing'), int(position*1000))
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,7 @@ class SyncServerProtocol(CommandProtocol):
|
|||||||
|
|
||||||
@arg_count(1)
|
@arg_count(1)
|
||||||
def handle_connected_playing(self, args):
|
def handle_connected_playing(self, args):
|
||||||
pass
|
self.factory.playing_received(self, args[0])
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash('|'.join((
|
return hash('|'.join((
|
||||||
@ -86,6 +86,9 @@ class SyncServerProtocol(CommandProtocol):
|
|||||||
def send_ping(self, value):
|
def send_ping(self, value):
|
||||||
self.send_message('ping', value)
|
self.send_message('ping', value)
|
||||||
|
|
||||||
|
def send_playing(self, who, what):
|
||||||
|
self.send_message('playing', who, what)
|
||||||
|
|
||||||
|
|
||||||
states = dict(
|
states = dict(
|
||||||
init = dict(
|
init = dict(
|
||||||
@ -243,3 +246,12 @@ class SyncFactory(Factory):
|
|||||||
def schedule_send_ping(self, watcher_proto, when=1):
|
def schedule_send_ping(self, watcher_proto, when=1):
|
||||||
reactor.callLater(when, self.send_ping_to, watcher_proto)
|
reactor.callLater(when, self.send_ping_to, watcher_proto)
|
||||||
|
|
||||||
|
def playing_received(self, watcher_proto, filename):
|
||||||
|
watcher = self.watchers.get(watcher_proto)
|
||||||
|
if not watcher:
|
||||||
|
return
|
||||||
|
|
||||||
|
for receiver in self.watchers.itervalues():
|
||||||
|
if receiver != watcher:
|
||||||
|
receiver.watcher_proto.send_playing(watcher.name, filename)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user