def _remote_handler_eb(self, failure, ms_id, trans_id): if log.isEnabledFor(logging.DEBUG): log.info('remote call failure: %s', failure.value, exc_info=(failure.type, failure.value, failure.getTracebackObject())) else: log.info('remote call failure: %s', failure.value) fatal = False if failure.check(CallResultError): body = self.encode_amf('_error', trans_id, *failure.value.get_error_args()) fatal = failure.value.is_fatal else: err = amf0.Object(code='NetStream.Failed', level='error', description=repr(failure.value)) body = self.encode_amf('_error', trans_id, None, err) ts = ms_time_wrapped(self.session_time()) self.muxer.sendMessage(ts, chunks.MSG_COMMAND, ms_id, body) if fatal: self.transport.loseConnection()
def _remote_handler_cb(self, result, ms_id, trans_id): # log.debug('remote call result: %r', result) if not isinstance(result, (tuple, list)): result = (result,) body = self.encode_amf('_result', trans_id, *result) ts = ms_time_wrapped(self.session_time()) self.muxer.sendMessage(ts, chunks.MSG_COMMAND, ms_id, body)
def _remote_handler_cb(self, result, ms_id, trans_id): # log.debug('remote call result: %r', result) if not isinstance(result, (tuple, list)): result = (result, ) body = self.encode_amf('_result', trans_id, *result) ts = ms_time_wrapped(self.session_time()) self.muxer.sendMessage(ts, chunks.MSG_COMMAND, ms_id, body)
def useSharedObject(self, ms_id, obj_name, persistance=False): if self._shared_objs.has_key(obj_name): raise SystemError("Shared object %s already in use" % obj_name) events = [{'data': '', 'type': const.SO_EVENT_TYPE_USE}] flags='\x00\x00\x00\x00\x00\x00\x00\x00' if persistance: flags = '\x00\x00\x00\x02\x00\x00\x00\x00' body = amf0.encode_so_update(obj_name, flags=flags, events=events) so = SharedObject(obj_name, persistance) self._shared_objs[obj_name] = so ts = ms_time_wrapped(self.session_time()) yield self.muxer.sendMessage(ts, chunks.MSG_SO, ms_id, body) defer.returnValue((yield so.readyd))
def useSharedObject(self, ms_id, obj_name, persistance=False): if self._shared_objs.has_key(obj_name): raise SystemError("Shared object %s already in use" % obj_name) events = [{'data': '', 'type': const.SO_EVENT_TYPE_USE}] flags = '\x00\x00\x00\x00\x00\x00\x00\x00' if persistance: flags = '\x00\x00\x00\x02\x00\x00\x00\x00' body = amf0.encode_so_update(obj_name, flags=flags, events=events) so = SharedObject(obj_name, persistance) self._shared_objs[obj_name] = so ts = ms_time_wrapped(self.session_time()) yield self.muxer.sendMessage(ts, chunks.MSG_SO, ms_id, body) defer.returnValue((yield so.readyd))
def releaseSharedObject(self, ms_id, obj_name): if not self._shared_objs.has_key(obj_name): raise SystemError("Shared object %s does not exists" % obj_name) so = self._shared_objs[obj_name] events = [{'data': '', 'type': const.SO_EVENT_TYPE_RELEASE}] flags='\x00\x00\x00\x00\x00\x00\x00\x00' if so.persistance: flags = '\x00\x00\x00\x02\x00\x00\x00\x00' body = amf0.encode_so_update(obj_name, flags=flags, events=events) del self._shared_objs[obj_name] ts = ms_time_wrapped(self.session_time()) yield self.muxer.sendMessage(ts, chunks.MSG_SO, ms_id, body) defer.returnValue(None)
def releaseSharedObject(self, ms_id, obj_name): if not self._shared_objs.has_key(obj_name): raise SystemError("Shared object %s does not exists" % obj_name) so = self._shared_objs[obj_name] events = [{'data': '', 'type': const.SO_EVENT_TYPE_RELEASE}] flags = '\x00\x00\x00\x00\x00\x00\x00\x00' if so.persistance: flags = '\x00\x00\x00\x02\x00\x00\x00\x00' body = amf0.encode_so_update(obj_name, flags=flags, events=events) del self._shared_objs[obj_name] ts = ms_time_wrapped(self.session_time()) yield self.muxer.sendMessage(ts, chunks.MSG_SO, ms_id, body) defer.returnValue(None)