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