@@ -8,6 +8,7 @@ var inherits = require('util').inherits;
8
8
var extend = require ( 'util' ) . _extend ;
9
9
10
10
var NODE_NEXT = require ( './tools/NODE_NEXT' ) ;
11
+ var nextTmpEventId = 1 ;
11
12
12
13
// Don't cache debugger module
13
14
delete require . cache [ module . id ] ;
@@ -181,8 +182,7 @@ V8Debug.prototype.registerAsyncCommand = function(name, func) {
181
182
} ;
182
183
183
184
V8Debug . prototype . command =
184
- V8Debug . prototype . sendCommand =
185
- V8Debug . prototype . emitEvent = sendCommand ;
185
+ V8Debug . prototype . sendCommand = sendCommand ;
186
186
function sendCommand ( name , attributes , userdata ) {
187
187
var message = {
188
188
seq : 0 ,
@@ -193,6 +193,17 @@ function sendCommand(name, attributes, userdata) {
193
193
binding . sendCommand ( JSON . stringify ( message ) ) ;
194
194
} ;
195
195
196
+ V8Debug . prototype . emitEvent = emitEvent ;
197
+ function emitEvent ( name , attributes , userdata ) {
198
+ var handlerName = 'tmpEvent-' + nextTmpEventId ++ ;
199
+ this . registerCommand ( handlerName , function ( request , response ) {
200
+ this . commandToEvent ( request , response ) ;
201
+ response . event = name ;
202
+ this . unregisterCommand ( handlerName ) ;
203
+ } . bind ( this ) ) ;
204
+ this . sendCommand ( handlerName , attributes , userdata ) ;
205
+ }
206
+
196
207
V8Debug . prototype . commandToEvent = function ( request , response ) {
197
208
response . type = 'event' ;
198
209
response . event = response . command ;
@@ -201,11 +212,6 @@ V8Debug.prototype.commandToEvent = function(request, response) {
201
212
delete response . request_seq ;
202
213
} ;
203
214
204
- V8Debug . prototype . registerEvent = function ( name ) {
205
- var proto = this . _DebugCommandProcessor ;
206
- proto . extendedProcessDebugJSONRequestHandles_ [ name ] = this . commandToEvent ;
207
- } ;
208
-
209
215
V8Debug . prototype . get =
210
216
V8Debug . prototype . runInDebugContext = function ( script ) {
211
217
if ( typeof script == 'function' ) script = '(' + script . toString ( ) + ')()' ;
@@ -243,8 +249,6 @@ V8Debug.prototype.enableWebkitProtocol = function() {
243
249
244
250
if ( this . _webkitProtocolEnabled ) return ;
245
251
246
- var nextTmpEventId = 1 ;
247
-
248
252
var DebuggerScriptSource ,
249
253
DebuggerScript ,
250
254
InjectedScriptSource ,
0 commit comments