Good explanation...
I did the #4, and half of my problems were solved, now when close
SocketServer, the case 'disconnect' is called, and I know the exactly
moment this :D.
But, I need to know when the user lost the connection and notify him.
Currently I implemented a ping, that send a packet from APE Client to
SocketServer, so I know when lost the connection, but with error margin.
I try insert the try-catch to detect when GET requisition will break, but
didn't work too.
When I have time, I will try to make the connection from the server side,
just like you said.
Thank!
Em segunda-feira, 7 de outubro de 2013 22h14min46s UTC-3, Louis Charette
escreveu:
>
> 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.
> 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)
>
> 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] <javascript:>>
> 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.
>
>
> <https://lh4.googleusercontent.com/-B9IuQwVcNMc/UlMJfjMCNEI/AAAAAAAAAZQ/lrs71Xj_L14/s1600/Screenshot+from+2013-10-07+16%3A08%3A08.png>
> thanks!
>
>
>
> Em segunda-feira, 7 de outubro de 2013 15h54min57s UTC-3, peter.r...@
> verpeteren.nl 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
>>
>> If the ape server dies, the client should fire a
>>
>> http://ape-project.org/static/jsdocs/client/symbols/APE.html#static_event_apeDisconnect
>>
>> 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
>> > [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
>> >> [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
>> >> [6] and the events here :
>> >> http://ape-project.org/static/jsdocs/client/symbols/APE.html [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 [1]
>> >>> ---
>> >>> APE Project (Ajax Push Engine)
>> >>> Official website : http://www.ape-project.org/ [2]
>> >>> Git Hub : http://github.com/APE-Project/ [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
>> >>> [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 [9]
>> > ---
>> > APE Project (Ajax Push Engine)
>> > Official website : http://www.ape-project.org/ [10]
>> > Git Hub : http://github.com/APE-Project/ [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
>> > [12].
>> >
>> >
>> > Links:
>> > ------
>> > [1] http://groups.google.com/group/ape-project?hl=en
>> > [2] http://www.ape-project.org/
>> > [3] http://github.com/APE-Project/
>> > [4] https://groups.google.com/groups/opt_out
>> > [5]
>> >
>> >
>> https://github.com/APE-Project/APE_JSF/blob/master/Source/Pipe/PipeProxy.js
>> > [6]
>> > http://ape-project.org/static/jsdocs/client/symbols/APE.PipeProxy.html
>> > [7] http://ape-project.org/static/jsdocs/client/symbols/APE.html
>> > [8]
>> > http://ape-project.org/wiki/index.php/index.php?page=JS+TCP+-+socket
>> > [9] http://groups.google.com/group/ape-project?hl=en
>> > [10] http://www.ape-project.org/
>> > [11] http://github.com/APE-Project/
>> > [12] https://groups.google.com/groups/opt_out
>>
>>
> --
> --
> 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]<javascript:>
> To unsubscribe from this group, send email to
> [email protected] <javascript:>
> For more options, visit this group at
> http://groups.google.com/group/ape-project?hl=en
> ---
> APE Project (Ajax Push Engine)
> Official website : http://www.ape-project.org/
> Git Hub : http://github.com/APE-Project/
>
> ---
> 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] <javascript:>.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
--
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
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/
---
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.