138 if message == "": |
138 if message == "": |
139 return False |
139 return False |
140 |
140 |
141 msg = QByteArray(message.encode("utf-8")) |
141 msg = QByteArray(message.encode("utf-8")) |
142 data = QByteArray("{0}{1}{2}{1}".format( |
142 data = QByteArray("{0}{1}{2}{1}".format( |
143 Connection.ProtocolMessage, SeparatorToken, msg.size())) + msg |
143 Connection.ProtocolMessage, SeparatorToken, msg.size()) |
|
144 .encode()) + msg |
144 return self.write(data) == data.size() |
145 return self.write(data) == data.size() |
145 |
146 |
146 def timerEvent(self, evt): |
147 def timerEvent(self, evt): |
147 """ |
148 """ |
148 Protected method to handle timer events. |
149 Protected method to handle timer events. |
264 """ |
265 """ |
265 Private slot to send a greeting message. |
266 Private slot to send a greeting message. |
266 """ |
267 """ |
267 greeting = QByteArray(self.__greetingMessage.encode("utf-8")) |
268 greeting = QByteArray(self.__greetingMessage.encode("utf-8")) |
268 data = QByteArray("{0}{1}{2}{1}".format( |
269 data = QByteArray("{0}{1}{2}{1}".format( |
269 Connection.ProtocolGreeting, SeparatorToken, greeting.size())) + \ |
270 Connection.ProtocolGreeting, SeparatorToken, greeting.size()) |
270 greeting |
271 .encode()) + greeting |
271 if self.write(data) == data.size(): |
272 if self.write(data) == data.size(): |
272 self.__isGreetingMessageSent = True |
273 self.__isGreetingMessageSent = True |
273 |
274 |
274 def __readDataIntoBuffer(self, maxSize=MaxBufferSize): |
275 def __readDataIntoBuffer(self, maxSize=MaxBufferSize): |
275 """ |
276 """ |
425 message = SeparatorToken.join(participants) |
426 message = SeparatorToken.join(participants) |
426 else: |
427 else: |
427 message = "<empty>" |
428 message = "<empty>" |
428 msg = QByteArray(message.encode("utf-8")) |
429 msg = QByteArray(message.encode("utf-8")) |
429 data = QByteArray("{0}{1}{2}{1}".format( |
430 data = QByteArray("{0}{1}{2}{1}".format( |
430 Connection.ProtocolParticipants, SeparatorToken, msg.size())) + msg |
431 Connection.ProtocolParticipants, SeparatorToken, msg.size()) |
|
432 .encode()) + msg |
431 self.write(data) |
433 self.write(data) |
432 |
434 |
433 def sendEditorCommand(self, projectHash, filename, message): |
435 def sendEditorCommand(self, projectHash, filename, message): |
434 """ |
436 """ |
435 Public method to send an editor command. |
437 Public method to send an editor command. |
440 @param message editor command to be sent (string) |
442 @param message editor command to be sent (string) |
441 """ |
443 """ |
442 msg = QByteArray("{0}{1}{2}{1}{3}".format( |
444 msg = QByteArray("{0}{1}{2}{1}{3}".format( |
443 projectHash, SeparatorToken, filename, message).encode("utf-8")) |
445 projectHash, SeparatorToken, filename, message).encode("utf-8")) |
444 data = QByteArray("{0}{1}{2}{1}".format( |
446 data = QByteArray("{0}{1}{2}{1}".format( |
445 Connection.ProtocolEditor, SeparatorToken, msg.size())) + msg |
447 Connection.ProtocolEditor, SeparatorToken, msg.size()) |
|
448 .encode()) + msg |
446 self.write(data) |
449 self.write(data) |
447 |
450 |
448 def __disconnected(self): |
451 def __disconnected(self): |
449 """ |
452 """ |
450 Private slot to handle the connection being dropped. |
453 Private slot to handle the connection being dropped. |