class TagMessageSocket: """ A socket wrapper that allows sending and receiving of TagMessages. Parameters ---------- rawSocket: socket """ def __init__(self, rawSocket): self.varLenSocket = VarLenSocket(rawSocket) def send(self, tagMessage): """ Send a TagMessage by converting it to a VarLenMessage. Parameters ---------- tagMessage: TagMessage The message to send. """ self.varLenSocket.send(tagMessage.toVarLenMessage()) def receive(self): """ Receive a TagMessage. Returns ------- TagMessage A TagMessage that has been converted from a VarLenMessage. """ # get the VarLenMessage vlm = self.varLenSocket.receive() # convert the VarLenMessage to TagMessage return TagMessage.fromVarLenMessage(vlm)
def __init__(self, rawSocket): self.varLenSocket = VarLenSocket(rawSocket)