Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import typing
- class Server:
- def main(self, port):
- # init socket at given port and listen it
- socket = object()
- socket.listen(port, self.handle_request)
- pass
- def handle_request(self, bytes_received):
- str_received = RequestHandler.handle_request(bytes_received)
- need_sync = 'need_sync' in str_received
- if need_sync:
- # asynchronous
- self.perform_sync()
- def perform_sync(self, *args):
- pass
- class RequestHandler:
- @staticmethod
- def send_request(ip, port, request_to_send):
- bytes_to_send = Serializer.from_str_to_bytes(request_to_send)
- # send_request_to(ip + ':' + port, bytes_to_send)
- pass
- @staticmethod
- def handle_request(bytes_from_client):
- str_received = Serializer.from_bytes_to_str(bytes_from_client)
- return str_received
- class Serializer:
- @staticmethod
- def from_bytes_to_str(bytes) -> str:
- pass
- @staticmethod
- def from_str_to_bytes(str) -> typing.List[bytes]:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement