本文整理汇总了C++中MessagePort::postMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ MessagePort::postMessage方法的具体用法?C++ MessagePort::postMessage怎么用?C++ MessagePort::postMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessagePort
的用法示例。
在下文中一共展示了MessagePort::postMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throwError
v8::Handle<v8::Value> V8MessagePort::postMessageCallback(const v8::Arguments& args)
{
INC_STATS("DOM.MessagePort.postMessage");
MessagePort* messagePort = V8DOMWrapper::convertToNativeObject<MessagePort>(V8ClassIndex::MESSAGEPORT, args.Holder());
RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(toWebCoreString(args[0]));
MessagePortArray portArray;
if (args.Length() > 1) {
if (!getMessagePortArray(args[1], portArray))
return v8::Undefined();
}
ExceptionCode ec = 0;
messagePort->postMessage(message.release(), &portArray, ec);
return throwError(ec);
}
示例2: exceptionState
void V8MessagePort::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage", "MessagePort", info.Holder(), info.GetIsolate());
MessagePort* messagePort = V8MessagePort::toNative(info.Holder());
MessagePortArray portArray;
ArrayBufferArray arrayBufferArray;
if (info.Length() > 1) {
const int transferablesArgIndex = 1;
if (!SerializedScriptValue::extractTransferables(info[transferablesArgIndex], transferablesArgIndex, portArray, arrayBufferArray, exceptionState, info.GetIsolate())) {
exceptionState.throwIfNeeded();
return;
}
}
RefPtr<SerializedScriptValue> message = SerializedScriptValue::create(info[0], &portArray, &arrayBufferArray, exceptionState, info.GetIsolate());
if (exceptionState.throwIfNeeded())
return;
messagePort->postMessage(message.release(), &portArray, exceptionState);
exceptionState.throwIfNeeded();
}
示例3: throwError
v8::Handle<v8::Value> V8MessagePort::postMessageCallback(const v8::Arguments& args)
{
INC_STATS("DOM.MessagePort.postMessage");
MessagePort* messagePort = V8MessagePort::toNative(args.Holder());
MessagePortArray portArray;
ArrayBufferArray arrayBufferArray;
if (args.Length() > 1) {
if (!extractTransferables(args[1], portArray, arrayBufferArray))
return v8::Undefined();
}
bool didThrow = false;
RefPtr<SerializedScriptValue> message =
SerializedScriptValue::create(args[0],
&portArray,
didThrow);
if (didThrow)
return v8::Undefined();
ExceptionCode ec = 0;
messagePort->postMessage(message.release(), &portArray, ec);
return throwError(ec);
}