@@ -58,12 +58,6 @@ cwc.runner.Connector = function(helper, name = 'Runner Connector') {
58
58
/** @type {!boolean } */
59
59
this . listen = false ;
60
60
61
- /** @private {!cwc.utils.Events} */
62
- this . events_ = new cwc . utils . Events ( this . name ) ;
63
-
64
- /** @type {!boolean } */
65
- this . directUpdate = false ;
66
-
67
61
/** @type {!string } */
68
62
this . token = String ( new Date ( ) . getTime ( ) ) ;
69
63
@@ -76,21 +70,24 @@ cwc.runner.Connector = function(helper, name = 'Runner Connector') {
76
70
/** @type {!number } */
77
71
this . pingTestWorker = 0 ;
78
72
73
+ /** @private {!cwc.utils.Events} */
74
+ this . events_ = new cwc . utils . Events ( this . name ) ;
75
+
79
76
/** @private {!cwc.utils.Logger} */
80
77
this . log_ = new cwc . utils . Logger ( this . name ) ;
81
78
} ;
82
79
83
80
84
81
/**
85
82
* Inits the runner instance.
86
- * @param {boolean= } opt_listen
83
+ * @param {boolean= } listen
87
84
*/
88
- cwc . runner . Connector . prototype . init = function ( opt_listen ) {
89
- if ( opt_listen ) {
85
+ cwc . runner . Connector . prototype . init = function ( listen ) {
86
+ if ( listen ) {
90
87
this . events_ . listen ( window , 'message' , this . handleMessage_ , false , this ) ;
91
88
this . listen = true ;
92
89
}
93
- this . addCommand ( '__direct_update__ ' , this . enableDirectUpdate_ , this ) ;
90
+ this . addCommand ( '__gamepad__ ' , this . handleGamepad_ , this ) ;
94
91
this . addCommand ( '__handshake__' , this . handleHandshake_ , this ) ;
95
92
this . addCommand ( '__pong__' , this . handlePong_ , this ) ;
96
93
} ;
@@ -113,15 +110,15 @@ cwc.runner.Connector.prototype.setTarget = function(target) {
113
110
114
111
/**
115
112
* @param {string! } command
116
- * @param {Object|number|string|Array= } optValue
113
+ * @param {Object|number|string|Array= } value
117
114
*/
118
- cwc . runner . Connector . prototype . send = function ( command , optValue ) {
115
+ cwc . runner . Connector . prototype . send = function ( command , value ) {
119
116
if ( ! this . target || ! this . target . contentWindow || ! this . targetLoaded ) {
120
117
return ;
121
118
}
122
119
123
120
this . target . contentWindow . postMessage ( {
124
- 'command' : command , 'value' : optValue } ,
121
+ 'command' : command , 'value' : value } ,
125
122
this . targetOrigin ) ;
126
123
} ;
127
124
@@ -138,15 +135,6 @@ cwc.runner.Connector.prototype.start = function() {
138
135
} ;
139
136
140
137
141
- /**
142
- * @private
143
- */
144
- cwc . runner . Connector . prototype . enableDirectUpdate_ = function ( ) {
145
- this . log_ . info ( 'Enabled direct update ...' ) ;
146
- this . directUpdate = true ;
147
- } ;
148
-
149
-
150
138
/**
151
139
* @param {!string } name
152
140
* @param {!function(?) } func
@@ -198,27 +186,27 @@ cwc.runner.Connector.prototype.addCommandProfile = function(profile, scope) {
198
186
199
187
/**
200
188
* @param {!function(?) } func
201
- * @param {?= } opt_scope
189
+ * @param {?= } scope
202
190
* @export
203
191
*/
204
- cwc . runner . Connector . prototype . setStartEvent = function ( func , opt_scope ) {
205
- this . addCommand ( '__start__' , func , opt_scope ) ;
192
+ cwc . runner . Connector . prototype . setStartEvent = function ( func , scope ) {
193
+ this . addCommand ( '__start__' , func , scope ) ;
206
194
} ;
207
195
208
196
209
197
/**
210
198
* @param {!string } name
211
199
* @param {!function(?) } func
212
- * @param {?= } opt_scope
200
+ * @param {?= } scope
213
201
* @export
214
202
*/
215
- cwc . runner . Connector . prototype . addMonitor = function ( name , func , opt_scope ) {
203
+ cwc . runner . Connector . prototype . addMonitor = function ( name , func , scope ) {
216
204
if ( ! func ) {
217
205
this . log_ . error ( 'Runner monitor function is undefined for' , name ) ;
218
206
return ;
219
207
}
220
- if ( opt_scope ) {
221
- this . monitor [ name ] = func . bind ( opt_scope ) ;
208
+ if ( scope ) {
209
+ this . monitor [ name ] = func . bind ( scope ) ;
222
210
} else {
223
211
this . monitor [ name ] = func ;
224
212
}
@@ -311,11 +299,11 @@ cwc.runner.Connector.prototype.ping = function() {
311
299
312
300
313
301
/**
314
- * @param {boolean= } opt_disable
302
+ * @param {boolean= } disable
315
303
* @export
316
304
*/
317
- cwc . runner . Connector . prototype . pingTest = function ( opt_disable ) {
318
- if ( opt_disable && this . pingTestWorker ) {
305
+ cwc . runner . Connector . prototype . pingTest = function ( disable ) {
306
+ if ( disable && this . pingTestWorker ) {
319
307
clearInterval ( this . pingTestWorker ) ;
320
308
} else if ( ! this . pingTestWorker ) {
321
309
this . pingTestWorker = setInterval ( this . ping . bind ( this ) , 0 ) ;
@@ -324,10 +312,9 @@ cwc.runner.Connector.prototype.pingTest = function(opt_disable) {
324
312
325
313
326
314
/**
327
- * @param {goog.events.BrowserEvent= } opt_event
328
315
* @private
329
316
*/
330
- cwc . runner . Connector . prototype . handleContentLoad_ = function ( opt_event ) {
317
+ cwc . runner . Connector . prototype . handleContentLoad_ = function ( ) {
331
318
this . targetLoaded = true ;
332
319
} ;
333
320
@@ -348,6 +335,14 @@ cwc.runner.Connector.prototype.handleMessage_ = function(event) {
348
335
} ;
349
336
350
337
338
+ /**
339
+ * @private
340
+ */
341
+ cwc . runner . Connector . prototype . handleGamepad_ = function ( ) {
342
+ console . log ( 'Enable Gamepad Support' ) ;
343
+ } ;
344
+
345
+
351
346
/**
352
347
* @param {!string } token
353
348
* @private
0 commit comments