1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
from src.qt_server import MyTcpServer
from src.qt_client import MyTcpClient
def start_client(app):
client = MyTcpClient()
client.connect_to_server()
if client.socket.waitForConnected(1000):
print("Connexion au serveur détectée!")
client.send_message("Client connecté au serveur \n")
if len(sys.argv) > 1:
video_url = sys.argv[1]
client.send_video_url(video_url)
client.send_message(f"url : {video_url}")
else:
print('Aucune connexion serveur détectée. Démarrage en mode local.')
start_local_app(app)
def start_local_app(app):
if len(sys.argv) < 2:
main = Vp()
else:
main = Vp(sys.argv[1])
server = MyTcpServer()
server.start_server(72954)
server.main_instance = main
main.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
QTimer.singleShot(0, lambda: start_client(app))
sys.exit(app.exec()) |
Partager