diff --git a/syncplay/client.py b/syncplay/client.py index 97f0a43..8663fef 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -5,6 +5,7 @@ import time from twisted.internet.protocol import ClientFactory from twisted.internet import reactor, task from syncplay.protocols import SyncClientProtocol +import traceback class SyncClientFactory(ClientFactory): def __init__(self, client, retry = 10): @@ -18,22 +19,23 @@ class SyncClientFactory(ClientFactory): def startedConnecting(self, connector): destination = connector.getDestination() - self._client.ui.showMessage('Connecting to {}:{}'.format(destination.host, destination.port)) + self._client.ui.showMessage('Attempting to connect to {}:{}'.format(destination.host, destination.port)) def clientConnectionLost(self, connector, reason): + traceback.print_stack() if self._timesTried < self.retry: self._timesTried += 1 - message = 'Connection lost, reconnecting' + message = 'Connection with server lost, attempting to reconnecting' self._client.ui.showMessage(message) self.reconnecting = True reactor.callLater(0.1*(2**self._timesTried), connector.connect) else: - message = 'Disconnected' + message = 'Disconnected from server' self._client.ui.showMessage(message) def clientConnectionFailed(self, connector, reason): if not self.reconnecting: - message = 'Connection failed' + message = 'Connection with server failed' self._client.ui.showMessage(message) self._client.stop(True) else: @@ -411,7 +413,7 @@ class SyncplayUserlist(object): if(self.currentUser.file): fileHasSameSizeAsYour = user.file['size'] == self.currentUser.file['size'] fileHasSameNameYour = user.file['name'] == self.currentUser.file['name'] - differentFileMessage = " (but their file size is different from yours!)" + differentFileMessage = " (their file size is different from yours!)" message += differentFileMessage if not fileHasSameSizeAsYour and fileHasSameNameYour else "" return message diff --git a/syncplay/players/mpc.py b/syncplay/players/mpc.py index e46e6a4..8cd2099 100644 --- a/syncplay/players/mpc.py +++ b/syncplay/players/mpc.py @@ -124,9 +124,7 @@ class MPCHCAPIPlayer(BasePlayer): self.__client.updatePlayerStatus(self.__client.getGlobalPaused(), self.__client.getGlobalPosition()) def __forcePause(self, paused): - i = 0 - while(paused <> self._mpcApi.isPaused() and i < 35): - i += 1 + while(paused <> self._mpcApi.isPaused()): self.setPaused(paused) time.sleep(0.1) time.sleep(0.1) diff --git a/syncplay/protocols.py b/syncplay/protocols.py index 2223d92..1920c3f 100644 --- a/syncplay/protocols.py +++ b/syncplay/protocols.py @@ -18,16 +18,16 @@ class JSONCommandProtocol(LineReceiver): elif command == "State": self.handleState(message[1]) elif command == "Error": - self.handleState(message[1]) + self.handleError(message[1]) else: self.dropWithError("Unknown Command\n" + message[1]) #TODO: log, not drop def printReceived(self, line): #TODO: remove -# print ">>i", line + #print ">>i", line pass def printSent(self, line): -# print "o<<", line + #print "o<<", line pass def lineReceived(self, line): @@ -68,7 +68,6 @@ class SyncClientProtocol(JSONCommandProtocol): self._client.destroyProtocol() def dropWithError(self, error): - print error self._client.ui.showErrorMessage(error) self._client.protocolFactory.stopRetrying() self.drop() @@ -89,6 +88,7 @@ class SyncClientProtocol(JSONCommandProtocol): self._client.setUsername(username) self._client.setRoom(roomName) self.logged = True + self._client.ui.showMessage("Successfully connected to server") self._client.sendFile() def sendHello(self): @@ -237,6 +237,7 @@ class SyncServerProtocol(JSONCommandProtocol): def dropWithError(self, error): print "Client drop: %s -- %s" % (self.transport.getPeer().host, error) + self.sendError(error) self.drop() def connectionLost(self, reason):