Fix networker send bugs.
This commit is contained in:
parent
a99a207c34
commit
095dc97d4e
@ -47,7 +47,7 @@ class Message:
|
||||
toReturn = {"mtype":self.mtype, "header":self.header, "ident__":"Message"}
|
||||
if type(self.content) == bytes or type(self.content) == bytearray:
|
||||
toReturn["contentb64"] = True
|
||||
toReturn["content"] = base64.b64encode(bytes(self.content)).decode('utf-8')
|
||||
toReturn["content"] = base64.b64encode(bytes(self.content)).decode()
|
||||
else:
|
||||
toReturn["contentb64"] = False
|
||||
toReturn["content"] = self.content
|
||||
@ -164,7 +164,12 @@ class Connection:
|
||||
def send(self, addr, m):
|
||||
if self.active and self.actives[addr]:
|
||||
try:
|
||||
toSendData = self.translator.toString(m)
|
||||
toSend = []
|
||||
if type(toSendData) == bytes or type(toSendData) == bytearray:
|
||||
toSend = bytes(self.translator.toString(m))
|
||||
else:
|
||||
toSend = bytes(self.translator.toString(m), encoding='utf-8')
|
||||
sendLength = len(toSend)
|
||||
if sendLength < 1:
|
||||
print("Message for: " + addr + " empty?")
|
||||
@ -189,6 +194,7 @@ class Connection:
|
||||
self.actives[addr] = False
|
||||
except:
|
||||
print("A send failure has occured for: " + addr)
|
||||
#print(traceback.format_exc())
|
||||
|
||||
def close(self):
|
||||
self.active = False
|
||||
|
Loading…
Reference in New Issue
Block a user