def load(self, data): msg, proto_length = struct.unpack_from("<II", data) self.msg = EMsg(clear_proto_bit(msg)) size = MsgHdrProtoBuf._size self._fullsize = size + proto_length self.proto.ParseFromString(data[size:self._fullsize])
def _parse_message(self, message): emsg_id, = struct.unpack_from("<I", message) emsg = EMsg(clear_proto_bit(emsg_id)) if not self.connected and emsg != EMsg.ClientLogOnResponse: return if emsg in ( EMsg.ChannelEncryptRequest, EMsg.ChannelEncryptResponse, EMsg.ChannelEncryptResult, ): msg = Msg(emsg, message) else: try: if is_proto(emsg_id): msg = MsgProto(emsg, message) else: msg = Msg(emsg, message, extended=True) except Exception as e: self._LOG.fatal( "Failed to deserialize message: %s (is_proto: %s)", str(emsg), is_proto(emsg_id)) self._LOG.exception(e) if self.verbose_debug: self._LOG.debug("Incoming: %s\n%s" % (repr(msg), str(msg))) else: self._LOG.debug("Incoming: %s", repr(msg)) self.emit(emsg, msg)
def load(self, data): ( msg, self.targetJobID, self.sourceJobID, ) = struct.unpack_from("<Iqq", data) self.msg = EMsg(msg)
def load(self, data): (msg, self.headerSize, self.headerVersion, self.targetJobID, self.sourceJobID, self.headerCanary, self.steamID, self.sessionID, ) = struct.unpack_from("<IBHqqBqi", data) self.msg = EMsg(msg) if self.headerSize != 36 or self.headerVersion != 2: raise RuntimeError("Failed to parse header")
def get_cmsg(emsg): """Get protobuf for a given EMsg :param emsg: EMsg :type emsg: :class:`steam.enums.emsg.EMsg`, :class:`int` :return: protobuf message """ if not isinstance(emsg, EMsg): emsg = EMsg(emsg) if emsg in cmsg_lookup_predefined: return cmsg_lookup_predefined[emsg] else: enum_name = emsg.name.lower() if enum_name.startswith("econ"): # special case for 'EconTrading_' enum_name = enum_name[4:] cmsg_name = "cmsg" + enum_name return cmsg_lookup.get(cmsg_name, None)
def get_cmsg(emsg): """Get protobuf for a given EMsg :param emsg: EMsg :type emsg: :class:`steam.enums.emsg.EMsg`, :class:`int` :return: protobuf message """ global cmsg_lookup, cmsg_lookup2 if not isinstance(emsg, EMsg): emsg = EMsg(emsg) if emsg in cmsg_lookup_predefined: return cmsg_lookup_predefined[emsg] else: enum_name = emsg.name.lower() if enum_name.startswith("econ"): # special case for 'EconTrading_' enum_name = enum_name[4:] cmsg_name = "cmsg" + enum_name if not cmsg_lookup: cmsg_list = steammessages_clientserver_pb2.__dict__ cmsg_list = fnmatch.filter(cmsg_list, 'CMsg*') cmsg_lookup = dict(zip(map(lambda x: x.lower(), cmsg_list), cmsg_list)) name = cmsg_lookup.get(cmsg_name, None) if name: return getattr(steammessages_clientserver_pb2, name) if not cmsg_lookup2: cmsg_list = steammessages_clientserver_2_pb2.__dict__ cmsg_list = fnmatch.filter(cmsg_list, 'CMsg*') cmsg_lookup2 = dict(zip(map(lambda x: x.lower(), cmsg_list), cmsg_list)) name = cmsg_lookup2.get(cmsg_name, None) if name: return getattr(steammessages_clientserver_2_pb2, name) return None
def msg(self, value): self.header.msg = EMsg(value)