def _send(self, emsg, data={}, proto=None, jobid=None): if not isinstance(data, dict): raise ValueError("data kwarg can only be a dict") if proto is None: proto = find_proto(emsg) if not issubclass(proto, google.protobuf.message.Message): raise ValueError( "Unable to find proto for emsg, or proto kwarg is invalid") message = proto() proto_fill_from_dict(message, data) header = GCMsgHdrProto(emsg) if jobid is not None: header.proto.job_id_source = jobid if self.verbose_debug: str_message = '' str_header = str(header) str_body = str(message) if str_header: str_message += "-- header ---------\n%s\n" % str_header if str_body: str_message += "-- message --------\n%s\n" % str_body self._LOG.debug("Outgoing: %s\n%s" % (repr(emsg), str_message)) else: self._LOG.debug("Outgoing: %s", repr(emsg)) GameCoordinator.send(self, header, message.SerializeToString())
def _send(self, emsg, data={}, proto=None, jobid=None): if not isinstance(data, dict): raise ValueError("data kwarg can only be a dict") if proto is None: proto = find_proto(emsg) if not issubclass(proto, google.protobuf.message.Message): raise ValueError("Unable to find proto for emsg, or proto kwarg is invalid") message = proto() proto_fill_from_dict(message, data) header = GCMsgHdrProto(emsg) if jobid is not None: header.proto.job_id_source = jobid if self.verbose_debug: str_message = '' str_header = str(header) str_body = str(message) if str_header: str_message += "-- header ---------\n%s\n" % str_header if str_body: str_message += "-- message --------\n%s\n" % str_body self._LOG.debug("Outgoing: %s\n%s" % (repr(emsg), str_message)) else: self._LOG.debug("Outgoing: %s", repr(emsg)) GameCoordinator.send(self, header, message.SerializeToString())
def _send(self, emsg, data={}, proto=None, jobid=None): if not isinstance(data, dict): raise ValueError("data kwarg can only be a dict") if proto is None: proto = find_proto(emsg) if not issubclass(proto, google.protobuf.message.Message): raise ValueError( "Unable to find proto for emsg, or proto kwarg is invalid") message = proto() for key, value in data.items(): if isinstance(value, list): attr = getattr(message, key) try: attr.extend(value) except TypeError: map(lambda args: attr.add(**args), value) else: setattr(message, key, value) header = GCMsgHdrProto(emsg) if jobid is not None: header.proto.job_id_source = jobid if self.verbose_debug: str_message = '' str_header = str(header) str_body = str(message) if str_header: str_message += "-- header ---------\n%s\n" % str_header if str_body: str_message += "-- message --------\n%s\n" % str_body self._LOG.debug("Outgoing: %s\n%s" % (repr(emsg), str_message)) else: self._LOG.debug("Outgoing: %s", repr(emsg)) GameCoordinator.send(self, header, message.SerializeToString())
def _send(self, emsg, data={}, proto=None, jobid=None): if not isinstance(data, dict): raise ValueError("data kwarg can only be a dict") if proto is None: proto = find_proto(emsg) if not issubclass(proto, google.protobuf.message.Message): raise ValueError("Unable to find proto for emsg, or proto kwarg is invalid") message = proto() for key, value in data.items(): if isinstance(value, list): attr = getattr(message, key) try: attr.extend(value) except TypeError: map(lambda args: attr.add(**args), value) else: setattr(message, key, value) header = GCMsgHdrProto(emsg) if jobid is not None: header.proto.job_id_source = jobid if self.verbose_debug: str_message = '' str_header = str(header) str_body = str(message) if str_header: str_message += "-- header ---------\n%s\n" % str_header if str_body: str_message += "-- message --------\n%s\n" % str_body self._LOG.debug("Outgoing: %s\n%s" % (repr(emsg), str_message)) else: self._LOG.debug("Outgoing: %s", repr(emsg)) GameCoordinator.send(self, header, message.SerializeToString())
def _process_gc_message(self, emsg, header, payload): emsg = get_emsg_enum(emsg) proto = find_proto(emsg) if proto is None: self._LOG.error("Failed to parse: %s" % repr(emsg)) return message = proto() message.ParseFromString(payload) if self.verbose_debug: self._LOG.debug("Incoming: %s\n%s\n---------\n%s" % (repr(emsg), str(header), str(message), )) else: self._LOG.debug("Incoming: %s", repr(emsg)) self.emit(emsg, message) if header.proto.job_id_target != 18446744073709551615: self.emit('job_%d' % header.proto.job_id_target, message)
def _process_gc_message(self, emsg, header, payload): emsg = get_emsg_enum(emsg) proto = find_proto(emsg) if proto is None: self._LOG.error("Failed to parse: %s" % repr(emsg)) return message = proto() message.ParseFromString(payload) if self.verbose_debug: self._LOG.debug("Incoming: %s\n%s\n---------\n%s" % ( repr(emsg), str(header), str(message), )) else: self._LOG.debug("Incoming: %s", repr(emsg)) self.emit(emsg, message) if header.proto.job_id_target != 18446744073709551615: self.emit('job_%d' % header.proto.job_id_target, message)