Firefox Plugins - Sockets

I always wanted to create a socket connection with the server and let the server manipulate the DOM page. For example, this can be used on the stock quotes page, so the server can call up new quotes as they appear.

I know this is a classic limitation (function?) Of the HTTP request / response protocol, but I think it can be implemented as a Firefox plugin (browser compatibility is not important for my application). Java / Flash solutions are unacceptable because (as far as I know) they live in a box and cannot interact with the DOM.

Can anyone confirm if this supports the Firefox plugin feature? Has someone already created this or something similar?

+4
source share
4 answers

You might want to see Comet , which is a fancy name for a long HTTP connection, where the server can push updates to the page.

+2
source

It should be possible. I developed an xulrunner application that connects to a TCP server using sockets. Expansion development is likely to have the same opportunities. I used the library from mozdev - JSLib . In particular, check the network code. The fact that there is a Firefox add-on for the JSlib add-on for Firefox makes you more confident.

Essentially, as I understand it, sockets are not part of JavaScript, but through XPCOM you can access raw sockets, as in any c / C ++ application.

Warning: JSLib doesn't seem to get much attention, and the mailing list is pretty sparse.

+2
source

Java / Flash solutions are unacceptable because (as far as I know) they live in a box and cannot interact with the DOM.

This is not really true for Java. You can interact with Java through JavaScript and modify the DOM.

http://stephengware.com/proj/javasocketbridge/

In this example, there are two JavaScript methods for interacting.

Send:

socket_send("This was sent via the socket\n\n");

Get:

on_socket_get(message){ more_code(message); }

+1
source

You can watch Comet

aka server click . This prevents the server from updating the client page directly, but all new data is sent to the page through a single connection.

Of course, the Firefox extension (as well as plugins , which are binary libraries that can do anything any other application can do) can also work with sockets. See 1 , 2 .

0
source

Source: https://habr.com/ru/post/1276348/


All Articles