Begin rewrite of socket connections

This commit is contained in:
2020-06-03 14:15:09 -05:00
parent fa6e5d8213
commit 66406ed739
2 changed files with 53 additions and 54 deletions

View File

@@ -13,10 +13,11 @@ MyVirtual = pyxinput.vController()
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((ip, port))
while True:
from_server = client.recv(8144)
from_server = client.makefile(mode='rb')
#Decode Sever message
decodedServerData = pickle.loads(from_server)
print("Raw Data:", str(decodedServerData))
unpickler = pickle.Unpickler(from_server)
decodedServerData = unpickler.load()
print("Raw Data:", decodedServerData)
# pyxinput will only accept values one at a time, so we need to apply the itme in the dictionary one by one
for event, state in decodedServerData.items():
MyVirtual.set_value(event, state)