namibia
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
APE.PipeProxy = new Class({
Extends: APE.Pipe,
initialize: function(core, options){
this.core = core || window.Ape;
this.ape = this.core;
this.initRequestMethod();
this.type = 'proxy';
if (options) {
this.init(options);
}
},
init: function(options){
this.pipe = options.pipe;
this.core.addPipe(this.getPubid(), this);
this.onRaw('proxy_event', this.rawProxyEvent);
this.ape.fireEvent('proxyPipeCreate', [this, options]);
},
reset: function() {
//close connection
},
close: function() {
//close connection
},
open: function(hostname, port){
if (this.core.status == 0) this.core.start(null, false);
//Adding a callback to request response to create a new pipe if this.pipe haven't been init
this.request.stack.add('PROXY_CONNECT', {'host':hostname, 'port':port}, this.pipe ? {} : {'callback':this.callback.bind(this)});
this.request.stack.send();
},
send: function(data){
this.request.send('SEND', {'msg':B64.encode(data)});
},
rawProxyEvent: function(resp){
switch (resp.data.event) {
case 'read':
var data = B64.decode(resp.data.data);
this.fireGlobalEvent('proxyRead', data)
if (this.onread) this.onread(data);
break;
case 'connect':
this.fireGlobalEvent('proxyConnect');
if (this.onopen) this.onopen();
break;
case 'close':
this.fireGlobalEvent('proxyClose');
if (this.onclose) this.onclose();
break;
}
},
callback: function(raw){
this.init(raw.data);
this.rawProxyEvent(raw);
}
});
APE.Core = new Class({
Extends: APE.Core,
/***
* This allow ape to be compatible with TCPSocket
*/
TCPSocket: APE.PipeProxy
});
|
Revision |
Author |
Commited |
Message |
df0489 ...
|
Mark |
Fri 14 Oct, 2016 10:01:00 +0000 |
|