I JUST SAW THE SERVER SIDE FILE /SCRIPTS/COMMANDS/PROXY.JS (I should
have look at this 2 hours ago lol). Everything I described (APE
Server
being the middleware between APE Client and the Socket Server) is
coded there. I'll fix the "disconnect" vs "close" thing there
instead.
- Louis
P.S.: I forgot to add this to my previous email. IF:
- the user is connected to APE and a socketServer
- the page is refreshed
- the transport is loongpolling
It will take a few second for the client to disappear from the
SocketServer the same way it takes a couple of second for the client
to disappear from the same server.
Le 2013-10-07 à 21:14, Louis Charette <[email protected] [39]>
a écrit :
I understand what's going on now.
1) First, I couldn't send anything to the Socket Server since I
didn't add "/n" at the end of my strings. I guess APE should do it
by himself…
2) When you use TCPSocket in the client (Browser), it's not the
client that connect to the socket but the APE Server itself. That's
why I couldn't use "localhost" as my TCPSocket server. APE was
running in a VM and the SocketServer on my computer. Since it's not
the browser that connect to the Socket Server, localhost didn't
point to my computer, but the VM where APE was running. What the APE
Client actually does when you create a new TCPSocket connection, it
create a new pipe to the APE server and use this pipe to send and
received data from APE Server to APE Client. The server himself
manage the connection to the socket. So it's:
APE Client --> APE Server --> SocketServer
and not :
APE Server <----- APE Client -----> Socket Server
3) That being said, if the APE Server is killed, you won't received
any "Socket disconnect event" since APE the pipe running from the
Client to the APE Server is shut at the same time. The Socket
connection (Between APE Server and Socket Server) should also be
shut when APE is killed, but I'm not sure, you may need to test
that. In that case (APE Server killled), you should listen to the
"apeDisconnect" event to tell the user the socket is now closed and
use the "apeReconnect" event to start the socket connection again.
4) Next, if the Socket server is killed (or the Socket Server kick
the client), APE Server will tell APE Client the connection has been
cut (via the pipes). BUT, there's an error in the APE Client. The
APE Client (in /Source/Pipe/PipeProxy.js) listen the the
"Proxy_event" raw and ship the data to a function called
"rawProxyEvent". This function will switch depending on which event
the APE Server send him (read, connect, close). The thing is, the
APE Server doesn't send a "CLOSE" event when the connection is shut,
but a "DISCONNECT" event. So, to make it work, you show edit the
file like this:
> Find:
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;
}
},
> Change to :
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':
case 'disconnect':
this.fireGlobalEvent('proxyClose');
if (this.onclose) this.onclose();
break;
}
},
(I'll make a fork of the Client files (APE_JSF) on GitHub and
submit a pull request to fix this for future use.)
5) In the same way as #4, if the user's internet is cut, he will
lose the connection from APE and the Socket at the same time as
described in #4.
6) Finally, the documentation on the new website is WRONG about
sockets for the Client Javascript. See:
http://ape-project.org/static/jsdocs/client/symbols/APE.PipeProxy.html#static_open
[36]. APE.PipeProxy doesn't actually exist in the Client (Again, APE
mix everyone up with the Client vs. Core functions). If you type
"Ape.PipeProxy" in the console of the browser, you'll get an
"undefined" error. The way to connect to a TCPSocket is the way you
did it, using "_SOCKET = NEW CLIENT.CORE.TCPSOCKET();_". Also, the
"send" page from the doc
(http://ape-project.org/static/jsdocs/client/symbols/APE.PipeProxy.html#static_send
[37]) doesn't actually says "send" anywhere, but use "write"
instead, which doesn't exist. The same way, "proxy.connect" is used
somewhere in the docs, but doesn't exist (proxy.open should be
used).
7) The TCPSocket events should be listen to the way you did it and
not the way the new documentation tell you to do it (By the way, the
old doc said the same thing). Technically both should produce the
same result, but using the documentation syntax, I got this error:
Uncaught TypeError: Function.prototype.apply: Arguments list has
wrong type
8) It should also be noted that APE Base64 encode the string sent
from APE Client to APE Server, then APE Server decode it and sent it
to the Socket Server. No big deal, but if you want to inspect the
console, you'll see it.
9) Finally, depending on what you want to do with this socket
connection, you could always use some server side coding to connect
APE Server to the socket and push the data to the pipes manually.
I'm not sure the impact this could have on performance, but…
Again, I'll try to update the wiki about all of this Socket business
soon so everyone can uses sockets o/ !
- Louis
Le 2013-10-07 à 15:37, Pablo Zandoná <[email protected] [38]>
a écrit :
The connection is from APE to normal socket (Java).
If the ape server dies, the connection on two sides should die,
correct?
So what is event called?
This picture has been taked in moment exactly that I killed the
aped.
Every request don't work more, and don't call any event.
[27]
thanks!
Em segunda-feira, 7 de outubro de 2013 15h54min57s UTC-3,
[email protected] [28] escreveu:
Hai
The connection that this TCPSocket makes, is that to the Ape
server?
I thought that this was meant to create on the client "another
'extra'
connection" to some server.
http://ape-project.org/wiki/index.php/index.php?page=JS+TCP+-+socket
[1]
If the ape server dies, the client should fire a
http://ape-project.org/static/jsdocs/client/symbols/APE.html#static_event_apeDisconnect
[2]
But it is probably that the 'other' connection stays intact.
Peter Reijnders
Pablo Zandoná schreef op 2013-10-07 15:46:
Thank you for atention!
I try this event onclose, but too don't work.
If you test this example,
http://ape-project.org/wiki/index.php/index.php?page=JS+TCP+-+socket
[3]
[8] , onclose too dont work. I dont know why.
For test, I killed the aped process, and in the this exact
time the
requisition GET, an error signaled on browser terminal, so I
have
thought who should call to method onclose.
Some idea?
Thanks!
Em sábado, 5 de outubro de 2013 14h40min56s UTC-3, Louis
Charette
escreveu:
Got lost for a minute here. TCPSOCKET is an alias to
APE.PIPEPROXY.
That's why I couldn't find it in the doc at first.
In that case, if I look at the client file PIPEPROXY.JS
(https://github.com/APE-Project/APE_JSF/blob/master/Source/Pipe/PipeProxy.js
[4]
[5]), it should be "ONCLOSE" and not "onDisconnect".
See documentation for more details on PipeProxy here:
http://ape-project.org/static/jsdocs/client/symbols/APE.PipeProxy.html
[5]
[6] and the events here :
http://ape-project.org/static/jsdocs/client/symbols/APE.html
[6] [7]
- Louis
Le 2013-10-04 à 09:47, Pablo Zandoná <[email protected]>
a
écrit :
Hello!
I have a sockClient on my app, but when I kill the aped on
my
server, the event don't call onDisconnect function. Why?
My socket:
var client = new APE.Client();
var coreApe = null;
var T
argin:0 0 0 40px;border:none;padding:0px">
ocketCore = null;
TCPSocket = this.core.TCPSocket;
coreApe = this.core;
coreApe.start();
});
client.addEvent('ready', function() {
socketCore = new TCPSocket();
socketCore.open(IP_CORE, PORTA_CORE);
socketCore.onopen = function() {
log_('Socket CORE conectado!');
};
socketCore.onread = function(data) {
data = utf8_decode(data);
json = stringToJson(data);
InterfaceClientCore.callback(json);
};
socketCore.onDisconnect = function() {
log_('socket.onDisconnect');
}
});
Thanks!
--
--
You received this message because you are subscribed to the
Google
Groups "APE Project" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en [7] [1]
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/ [8] [2]
Git Hub : http://github.com/APE-Project/ [9] [3]
---
You received this message because you are subscribed to the
Google Groups "APE Project" group.
To unsubscribe from this group and stop receiving emails
from it,
send an email to [email protected].
For more options, visit
https://groups.google.com/groups/opt_out [10]
[4].
--
--
You received this message because you are subscribed to the
Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en [11] [9]
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/ [12] [10]
Git Hub : http://github.com/APE-Project/ [13] [11]
---
You received this message because you are subscribed to the
Google
Groups "APE Project" group.
To unsubscribe from this group and stop receiving emails from
it,
send an email to [email protected].
For more options, visit
https://groups.google.com/groups/opt_out [14]
[12].
Links:
------
[1] http://groups.google.com/group/ape-project?hl=en [15]
[2] http://www.ape-project.org/ [16]
[3] http://github.com/APE-Project/ [17]
[4] https://groups.google.com/groups/opt_out [18]
[5]
https://github.com/APE-Project/APE_JSF/blob/master/Source/Pipe/PipeProxy.js
[19]
[6]
http://ape-project.org/static/jsdocs/client/symbols/APE.PipeProxy.html
[20]
[7]
http://ape-project.org/static/jsdocs/client/symbols/APE.html
[21]
[8]
http://ape-project.org/wiki/index.php/index.php?page=JS+TCP+-+socket
[22]
[9] http://groups.google.com/group/ape-project?hl=en [23]
[10] http://www.ape-project.org/ [24]
[11] http://github.com/APE-Project/ [25]
[12] https://groups.google.com/groups/opt_out [26]
--
--
You received this message because you are subscribed to the
Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
[29]
To unsubscribe from this group, send email to
[email protected] [30]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en [31]
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/ [32]
Git Hub : http://github.com/APE-Project/ [33]
---
You received this message because you are subscribed to the
Google Groups "APE Project" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected] [34].
For more options, visit https://groups.google.com/groups/opt_out
[35].
--
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en [40]
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/ [41]
Git Hub : http://github.com/APE-Project/ [42]
---
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out
[43].
Links:
------
[1]
http://ape-project.org/wiki/index.php/index.php?page=JS+TCP+-+socket
[2]
http://ape-project.org/static/jsdocs/client/symbols/APE.html#static_event_apeDisconnect
[3]
http://ape-project.org/wiki/index.php/index.php?page=JS+TCP+-+socket
[4]
https://github.com/APE-Project/APE_JSF/blob/master/Source/Pipe/PipeProxy.js
[5]
http://ape-project.org/static/jsdocs/client/symbols/APE.PipeProxy.html
[6] http://ape-project.org/static/jsdocs/client/symbols/APE.html
[7] http://groups.google.com/group/ape-project?hl=en
[8] http://www.ape-project.org/
[9] http://github.com/APE-Project/
[10] https://groups.google.com/groups/opt_out
[11] http://groups.google.com/group/ape-project?hl=en
[12] http://www.ape-project.org/
[13] http://github.com/APE-Project/
[14] https://groups.google.com/groups/opt_out
[15] http://groups.google.com/group/ape-project?hl=en
[16] http://www.ape-project.org/
[17] http://github.com/APE-Project/
[18] https://groups.google.com/groups/opt_out
[19]
https://github.com/APE-Project/APE_JSF/blob/master/Source/Pipe/PipeProxy.js
[20]
http://ape-project.org/static/jsdocs/client/symbols/APE.PipeProxy.html
[21] http://ape-project.org/static/jsdocs/client/symbols/APE.html
[22]
http://ape-project.org/wiki/index.php/index.php?page=JS+TCP+-+socket
[23] http://groups.google.com/group/ape-project?hl=en
[24] http://www.ape-project.org/
[25] http://github.com/APE-Project/
[26] https://groups.google.com/groups/opt_out
[27]
https://lh4.googleusercontent.com/-B9IuQwVcNMc/UlMJfjMCNEI/AAAAAAAAAZQ/lrs71Xj_L14/s1600/Screenshot+from+2013-10-07+16%3A08%3A08.png
[28] http://verpeteren.nl/
[29] mailto:[email protected]
[30] mailto:[email protected]
[31] http://groups.google.com/group/ape-project?hl=en
[32] http://www.ape-project.org/
[33] http://github.com/APE-Project/
[34] mailto:[email protected]
[35] https://groups.google.com/groups/opt_out
[36]
http://ape-project.org/static/jsdocs/client/symbols/APE.PipeProxy.html#static_open
[37]
http://ape-project.org/static/jsdocs/client/symbols/APE.PipeProxy.html#static_send
[38] mailto:[email protected]
[39] mailto:[email protected]
[40] http://groups.google.com/group/ape-project?hl=en
[41] http://www.ape-project.org/
[42] http://github.com/APE-Project/
[43] https://groups.google.com/groups/opt_out