diff --git a/syncplay/messages.py b/syncplay/messages.py index 09c0105..78d1210 100755 --- a/syncplay/messages.py +++ b/syncplay/messages.py @@ -82,6 +82,7 @@ en = { "commandlist-notification/toggle" : u"\tt - toggles whether you are ready to watch or not", "commandlist-notification/create" : "\tc [name] - create managed room using name of current room", "commandlist-notification/auth" : "\ta [password] - authenticate as room operator with operator password", + "commandlist-notification/chat" : "\tch [message] - send a chat message in a room", "syncplay-version-notification" : "Syncplay version: {}", # syncplay.version "more-info-notification" : "More info available at: {}", # projectURL diff --git a/syncplay/protocols.py b/syncplay/protocols.py index 35cc717..bcda382 100644 --- a/syncplay/protocols.py +++ b/syncplay/protocols.py @@ -241,6 +241,9 @@ class SyncClientProtocol(JSONCommandProtocol): "password": password } }) + def handleChat(self,message): + self._client.ui.showMessage(message) + #TODO def setReady(self, isReady, manuallyInitiated=True): self.sendSet({ @@ -330,7 +333,9 @@ class SyncServerProtocol(JSONCommandProtocol): self._logged = True self.sendHello(version) def handleChat(self,chatMessage): - #TODO + if self._factory.chat: + self._factory.sendChat(self._watcher,chatMessage) + def setWatcher(self, watcher): self._watcher = watcher diff --git a/syncplay/server.py b/syncplay/server.py index d155896..efaaf50 100644 --- a/syncplay/server.py +++ b/syncplay/server.py @@ -129,6 +129,9 @@ class SyncFactory(Factory): except ValueError: self._roomManager.broadcastRoom(watcher, lambda w: w.sendControlledRoomAuthStatus(False, watcher.getName(), room._name)) + def sendChat(self,watcher,message): + self._roomManager.broadcastRoom(watcher, lambda w: w.sendChatMessage(message)) + def setReady(self, watcher, isReady, manuallyInitiated=True): watcher.setReady(isReady) self._roomManager.broadcastRoom(watcher, lambda w: w.sendSetReady(watcher.getName(), watcher.isReady(), manuallyInitiated)) @@ -368,6 +371,9 @@ class Watcher(object): def sendControlledRoomAuthStatus(self, success, username, room): self._connector.sendControlledRoomAuthStatus(success, username, room) + def sendChatMessage(self,message): + self._connector.sendMessage({"Chat" : message}) + def sendSetReady(self, username, isReady, manuallyInitiated=True): self._connector.sendSetReady(username, isReady, manuallyInitiated) diff --git a/syncplay/ui/consoleUI.py b/syncplay/ui/consoleUI.py index 94d0dbf..1726ccd 100644 --- a/syncplay/ui/consoleUI.py +++ b/syncplay/ui/consoleUI.py @@ -175,6 +175,7 @@ class ConsoleUI(threading.Thread): self.showMessage(getMessage("commandlist-notification/toggle"), True) self.showMessage(getMessage("commandlist-notification/create"), True) self.showMessage(getMessage("commandlist-notification/auth"), True) + self.showMessage(getMessage("commandlist-notification/chat"), True) self.showMessage(getMessage("syncplay-version-notification").format(syncplay.version), True) self.showMessage(getMessage("more-info-notification").format(syncplay.projectURL), True)