Add socket respond capability

This commit is contained in:
lash 2022-04-10 17:18:54 +00:00
parent d0dbaad1f2
commit 4f83b20719
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746

View File

@ -105,4 +105,15 @@ class SessionController:
raise ClientInputError() raise ClientInputError()
logg.info('recv {} bytes'.format(len(data))) logg.info('recv {} bytes'.format(len(data)))
return data return (srvs, data,)
def respond_put(self, srvs, r, extra_data=None):
v = r.to_bytes(4, byteorder='big')
if extra_data != None:
v += strip_0x(extra_data).encode('utf-8')
try:
srvs.send(v)
logg.debug('{} bytes sent'.format(len(v)))
except BrokenPipeError:
logg.debug('they just hung up. how rude.')