85 )): |
85 )): |
86 # handle sending of objects of unsupported types |
86 # handle sending of objects of unsupported types |
87 data = str(data) |
87 data = str(data) |
88 |
88 |
89 packedData = json.dumps([fx, fn, data]) |
89 packedData = json.dumps([fx, fn, data]) |
90 if sys.version_info[0] >= 3: |
90 packedData = bytes(packedData, 'utf-8') |
91 packedData = bytes(packedData, 'utf-8') |
|
92 header = struct.pack( |
91 header = struct.pack( |
93 b'!II', len(packedData), adler32(packedData) & 0xffffffff) |
92 b'!II', len(packedData), adler32(packedData) & 0xffffffff) |
94 self.connection.sendall(header) |
93 self.connection.sendall(header) |
95 self.connection.sendall(packedData) |
94 self.connection.sendall(packedData) |
96 |
95 |
162 continue |
161 continue |
163 |
162 |
164 if adler32(packedData) & 0xffffffff != datahash: |
163 if adler32(packedData) & 0xffffffff != datahash: |
165 raise RuntimeError('Hashes not equal') |
164 raise RuntimeError('Hashes not equal') |
166 |
165 |
167 if sys.version_info[0] >= 3: |
166 packedData = packedData.decode('utf-8') |
168 packedData = packedData.decode('utf-8') |
|
169 |
167 |
170 fx, fn, data = json.loads(packedData) |
168 fx, fn, data = json.loads(packedData) |
171 if fx == 'INIT': |
169 if fx == 'INIT': |
172 ret = self.__initClientService(fn, *data) |
170 ret = self.__initClientService(fn, *data) |
173 elif fx.startswith("batch_"): |
171 elif fx.startswith("batch_"): |