[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Processing SVG from TCP socket

Jay Braun

7/29/2015 11:00:00 PM

I have been asked to modernize the graphics of a legacy project so that it can be viewed in a browser, and I think SVG with Javascript might do the trick. Just need a couple of pointers.

This old application, a simulation model, outputs a description of various objects to be depicted graphically on a remote workstation. The application itself has no graphical capabilities, and no internal tracking of updates. It simply dumps a snapshot every few seconds.

The "dump" is in a custom format, but the information can easily be described with SVG. I don't need any help with that, and have produced one sample snapshot in SVG and displayed it in a browser. Piece of cake.

Here are my questions:

1) How can I get a browser to process SVG (or any XML for that matter) that is coming in via a TCP socket? (I'd like to stick with TCP since the legacy application already has code to use that protocol.) I expect that Javascript or some other programming capability can help here; can you point me to a reference?

2) I need to "clear" the display when a new dump begins, and draw the brand new dump. Any thought on how to do that?

3) I will eventually need some event handling, especially mouse clicks.

Thank you for your recommendations.

Jay
5 Answers

Martin Honnen

7/30/2015 8:35:00 AM

0

Jay Braun wrote:

> 1) How can I get a browser to process SVG (or any XML for that
> matter) that is coming in via a TCP socket? (I'd like to stick with
> TCP since the legacy application already has code to use that
> protocol.) I expect that Javascript or some other programming
> capability can help here; can you point me to a reference?

Inside the browser you can do HTTP requests using XMLHttpRequest
https://developer.mozilla.org/de/docs/Web/API/XMLHttpRequest/Using_XMLH...
or open a WebSocket connection
https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_ap....
I am not aware of any TCP socket support.


> 2) I need to "clear" the display when a new dump begins, and draw the
> brand new dump. Any thought on how to do that?

Are you using SVG within HTML? Or solely SVG? In any case, using W3C DOM
scripting you can remove nodes and insert new ones respectively replace
nodes. On the other hand if you want to replace the whole document
displayed every 10 seconds then a HTTP refresh
*https://en.wikipedia.org/wiki/Me...) might be easier, assuming
your legacy app can do HTTP instead of TCP.

> 3) I will eventually need some event handling, especially mouse
> clicks.

The SVG elements have event handler attributes, see
http://www.w3.org/TR/SVG11/script.html#Event... and you can also
attach event listeners using the W3C DOM method addEventListener.



--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

Evertjan.

7/30/2015 8:51:00 AM

0

Martin Honnen <mahotrash@yahoo.de> wrote on 30 Jul 2015 in
comp.lang.javascript:

> I am not aware of any TCP socket support.

read this, [not my piece of cake].

<http://www.html5rocks.com/en/tutorials/websockets/b...

<http://stackoverflow.com/questions/12407778/connecting-to-tcp-so...
browser-using-javascript>



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Martin Honnen

7/30/2015 9:04:00 AM

0

Evertjan. wrote:
> Martin Honnen <mahotrash@yahoo.de> wrote on 30 Jul 2015 in
> comp.lang.javascript:
>
>> I am not aware of any TCP socket support.
>
> read this, [not my piece of cake].
>
> <http://www.html5rocks.com/en/tutorials/websockets/b...

I did mention WebSocket ("open a WebSocket connection") in my post,
although with a different link.




--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

Richard Maher

7/30/2015 9:43:00 AM

0

On 7/30/2015 7:00 AM, Jay Braun wrote:
>Shit that didn't wrap
>

If you wish to stick with existing server TCP/IP sockets then you'll
need a Java Applet in the browser.

Evertjan.

7/30/2015 10:30:00 AM

0

Martin Honnen <mahotrash@yahoo.de> wrote on 30 Jul 2015 in
comp.lang.javascript:

> Evertjan. wrote:
>> Martin Honnen <mahotrash@yahoo.de> wrote on 30 Jul 2015 in
>> comp.lang.javascript:
>>
>>> I am not aware of any TCP socket support.
>>
>> read this, [not my piece of cake].
>>
>> <http://www.html5rocks.com/en/tutorials/websockets/b...
>
> I did mention WebSocket ("open a WebSocket connection") in my post,
> although with a different link.

Seems I was right about the cake.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)