support ipv6 peers
This commit is contained in:
parent
e4dd22b0bd
commit
df1eb190cb
1 changed files with 13 additions and 3 deletions
|
@ -92,7 +92,10 @@ class Player(Thread):
|
|||
|
||||
def ping(self):
|
||||
data = 'NEXT'
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
if ':' in self.peer:
|
||||
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
||||
else:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
logger.debug("ping: %s %s", self.peer, data)
|
||||
sock.sendto(bytes(data + "\n", "utf-8"), self.peer)
|
||||
received = str(sock.recv(1024), "utf-8")
|
||||
|
@ -105,7 +108,11 @@ class Player(Thread):
|
|||
|
||||
def get_position(self):
|
||||
try:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
if ':' in self.peer:
|
||||
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
||||
else:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
||||
sock.settimeout(1)
|
||||
data = 'POS'
|
||||
sock.sendto(bytes(data + "\n", "utf-8"), self.peer)
|
||||
|
@ -122,7 +129,8 @@ def main():
|
|||
prefix = os.path.expanduser('~/Videos/CDOSEA')
|
||||
|
||||
parser = argparse.ArgumentParser(description='play 2 screens in sync')
|
||||
parser.add_argument('--peer', help='ip[:port] of peer', required=True)
|
||||
parser.add_argument('--peer', help='ipof peer', required=True)
|
||||
parser.add_argument('--peer', help='port of peer')
|
||||
parser.add_argument('--port', type=int, help='local port', default=DEFAULT_PORT)
|
||||
parser.add_argument('--playlist', help='play.m3u', default=playlist)
|
||||
parser.add_argument('--prefix', help='video location', default=prefix)
|
||||
|
@ -136,6 +144,8 @@ def main():
|
|||
else:
|
||||
peer = (args.peer, DEFAULT_PORT)
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
DEBUG = args.debug
|
||||
if DEBUG:
|
||||
log_format = '%(asctime)s:%(levelname)s:%(name)s:%(message)s'
|
||||
|
|
Loading…
Reference in a new issue