return scope.Close(v8_event);
}
-// static
-string16 Event::GetReturnValue(v8::Handle<v8::Object> event) {
- v8::HandleScope scope;
- v8::Local<v8::Value> json = event->Get(v8::String::New("returnValue"));
- return V8ValueToUTF16(json);
-}
-
-
void Event::SetSenderAndMessage(IPC::Sender* sender, IPC::Message* message) {
DCHECK(!sender_);
DCHECK(!message_);
return node::ThrowError("Event is already destroyed");
if (event->sender_ == NULL)
- return node::ThrowError("Can only send reply to synchronous events");
+ return node::ThrowError("Can only send reply to synchronous events once");
- string16 json = GetReturnValue(args.This());
+ string16 json = V8ValueToUTF16(args[0]);
AtomViewHostMsg_Message_Sync::WriteReplyParams(event->message_, json);
event->sender_->Send(event->message_);
+ event->sender_ = NULL;
+ event->message_ = NULL;
return v8::Undefined();
}
// Create a V8 Event object.
static v8::Handle<v8::Object> CreateV8Object();
- // Get JSON string of the event.returnValue from a Event object.
- static string16 GetReturnValue(v8::Handle<v8::Object> event);
-
// Pass the sender and message to be replied.
void SetSenderAndMessage(IPC::Sender* sender, IPC::Message* message);
process.on 'ATOM_INTERNAL_MESSAGE', (args...) =>
@emit(args...)
process.on 'ATOM_INTERNAL_MESSAGE_SYNC', (channel, event, args...) =>
- returnValue = null
- get = -> returnValue
- set = (value) ->
- throw new Error('returnValue can be only set once') if returnValue?
- returnValue = JSON.stringify(value)
- event.sendReply()
-
- Object.defineProperty event, 'returnValue', {get, set}
- Object.defineProperty event, 'result', {get, set}
+ set = (value) -> event.sendReply JSON.stringify(value)
+
+ Object.defineProperty event, 'returnValue', {set}
+ Object.defineProperty event, 'result', {set}
@emit(channel, event, args...)