class msg_alert(MsgSerializable): command = b"alert" def __init__(self, protover=PROTO_VERSION): super(msg_alert, self).__init__(protover) self.alert = CAlert() @classmethod def msg_deser(cls, f, protover=PROTO_VERSION): c = cls() c.alert = CAlert.stream_deserialize(f) return c def msg_ser(self, f): self.alert.stream_serialize(f) def __repr__(self): return "msg_alert(alert=%s)" % (repr(self.alert), )
class msg_alert(MsgSerializable): command = b"alert" def __init__(self, protover=PROTO_VERSION): super(msg_alert, self).__init__(protover) self.alert = CAlert() @classmethod def msg_deser(cls, f, protover=PROTO_VERSION): c = cls() c.alert = CAlert.stream_deserialize(f) return c def msg_ser(self, f): self.alert.stream_serialize(f) def __repr__(self): return "msg_alert(alert=%s)" % (repr(self.alert),)
def test_serialization(self): alert = CAlert() alert.setCancel = [1, 2, 3] alert.strComment = b"Comment" stream = _BytesIO() alert.stream_serialize(stream) serialized = _BytesIO(stream.getvalue()) deserialized = CAlert.stream_deserialize(serialized) self.assertEqual(deserialized, alert)
def msg_deser(cls, f, protover=PROTO_VERSION): c = cls() c.alert = CAlert.stream_deserialize(f) return c
def __init__(self, protover=PROTO_VERSION): super(msg_alert, self).__init__(protover) self.alert = CAlert()