本文整理汇总了TypeScript中gen/msg_generated.Base.getRootAsBase方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Base.getRootAsBase方法的具体用法?TypeScript Base.getRootAsBase怎么用?TypeScript Base.getRootAsBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gen/msg_generated.Base
的用法示例。
在下文中一共展示了Base.getRootAsBase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: sendSync
export function sendSync(
builder: flatbuffers.Builder,
innerType: msg.Any,
inner: flatbuffers.Offset,
data?: ArrayBufferView
): null | msg.Base {
const [cmdId, resBuf] = sendInternal(builder, innerType, inner, data, true);
util.assert(cmdId >= 0);
if (resBuf == null) {
return null;
} else {
const u8 = new Uint8Array(resBuf!);
const bb = new flatbuffers.ByteBuffer(u8);
const baseRes = msg.Base.getRootAsBase(bb);
errors.maybeThrowError(baseRes);
return baseRes;
}
}
示例2: handleAsyncMsgFromRust
export function handleAsyncMsgFromRust(ui8: Uint8Array) {
// If a the buffer is empty, recv() on the native side timed out and we
// did not receive a message.
if (ui8 && ui8.length) {
const bb = new flatbuffers.ByteBuffer(ui8);
const base = msg.Base.getRootAsBase(bb);
const cmdId = base.cmdId();
const promise = promiseTable.get(cmdId);
util.assert(promise != null, `Expecting promise in table. ${cmdId}`);
promiseTable.delete(cmdId);
const err = errors.maybeError(base);
if (err != null) {
promise!.reject(err);
} else {
promise!.resolve(base);
}
}
// Fire timers that have become runnable.
fireTimers();
}