File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ function Connection(stream, server) {
20
20
this . stream = stream ;
21
21
}
22
22
23
+ this . generate = generate ;
23
24
this . buffer = null ;
24
25
this . packet = { } ;
25
26
this . skip = false ;
@@ -116,14 +117,14 @@ Connection.prototype.parse = function() {
116
117
for ( var k in protocol . types ) {
117
118
var v = protocol . types [ k ] ;
118
119
119
- Connection . prototype [ v ] = function ( type ) {
120
- return function ( opts ) {
121
- var p = generate [ type ] ( opts ) ;
122
- if ( p instanceof Error ) {
123
- this . emit ( 'error' , p )
124
- } else {
125
- this . stream . write ( p ) ;
126
- }
127
- }
128
- } ( v ) ;
120
+ var fun = "" +
121
+ " var p = this.generate." + v + "(arguments[0]); " +
122
+ " if (p instanceof Error) { " +
123
+ " this.emit('error', p) " +
124
+ " } else { " +
125
+ " this.stream.write(p); " +
126
+ " } "
127
+ " } " ;
128
+
129
+ Connection . prototype [ v ] = new Function ( fun ) ;
129
130
}
You can’t perform that action at this time.
0 commit comments