Does anybody sees a way to listen to cross iframe/window communication that is being done using the javascript postMessages ?
Best would be using the chrome.debugger in the background page of an extension. I see that I can listen to HTTP-Traffic using the "Network.requestWillBeSent" and "Network.responseReceived" events. But I would like also to listen to the internal communication on the page.
If my question isn't clear enough, please let me know, I'll try to clarify it more.
Thank you in advance !
Run a content script and bind a message event listener. This event listener will then be invoked postMessage is called.
Related
If I have en external process post a message as bot, let's say !help how can make Errbot respond to it? Currently it ignores messages coming from errbot itself. I could not find a configuration option for this.
Good question: It is in the contract of each backend to detect and filter out the messages coming from the bot itself.
This design choice is mainly to avoid weird infinite loop behavior etc.
In general if the bot emits something and needs to react from it, why not doing that at that point instead of waiting for its own response?
How is it possible to add a 'disconnect' event whenever I leave a page that is intercepted by my single page application engine?
I have certain events set up (kind of like streaming events on YouTube) and each requires its own socket connection. I now set up a single-page engine on Angular that allows switching between these events.
I used to rely on the 'disconnect' event to let me know when someone has left the event, but they don't work anymore - the socket never shuts off if I leave via my single-page navigation.
Is there any way to configure the socket to still disconnect?
My less-than-ideal approach was to create a new instance of the socket connection on a controller of every page to which I can navigate from the event page, and forbid multiple connections.
If anybody has a better idea, I would love to hear it.
Thanks a lot.
You may call it manually since you are in control of page navigation - whenever client is navigating away from one page, call
socket.disconnect();
socket.close();
This will ensure that when client is navigating away from one page the socket gets disconnected before that.
How would I send a command to Node.js
I have a jquery / javascript page which detects on keypress W,A,S Or D and then triggers an event to change the canvas.
The next step in this is to then trigger a event on a Node.js server using (I think) Websockets.
Most tutorials I have found are the other way around with sending data to the client.
Does anyone have places with tutorials on how I would do this?
Thanks - Ryan
Use web sockets, tutorial is here http://socket.io/
You can do this with normal ajax calls to Node.js. If you want something more fancy checkout socket.io.
I have a java based web application(struts 1.2). I have a requirement to display a status on the frontend (jsp). Now the status might change which my server gets notified by another server. But I want this status change to be notified to the browser.
I don't want to make a refresh at intervals. Rather I have to implement something like done in gmail chat, ie. the browser gets notified by changing events on the server.
Any ideas on how to go about this?
I was thinking on lines of opening a request to server for status, and at the server end I would hold the request and wouldn't respond back until there is a status change. Any pointers, examples on this?
Best possible solution will be to make use of XMPP protocol. It's standardized and a lot of open source solutions will get you started within minutes. You can use combination of Smack, StropheJS and Openfire to get your java based app work as desired.
There's a method called Long Polling (Comet). It basically sends a request to the server. The request thread created on the server simply waits for new data for the user, with a time limit of maybe 1 minute or more. When new data is available it is returned.
The main problem is to tackle the server-side issue, you don't want to have one thread for every user just waiting for new data. Of course you could use some asynchronous methods depending on your back-end.
Ref: http://en.wikipedia.org/wiki/Push_technology
Alternative way would be to use WebSockets. The problem is that it's not supported by all browsers today.
Is there any possible way to have browsers communicating to each other over lan/wan without the use of a server (direct peer-to-peer)?
Looks like there may be hope on the horizon: http://www.w3.org/TR/webrtc/
Yes you can try http://httprelay.io with the AJAX calls. It is simple as that:
* Send data: POST https://demo.httprelay.io/link/your_secret_channel_id
* Receive data GET https://demo.httprelay.io/link/your_secret_channel_id
IIRC, Opera released some kind of addition to their browser that embedded a webserver for just that functionality:
http://unite.opera.com/
Not sure it really went anywhere, but I think its time will come.
In pure HTML/Javascript? Probably not.
To my knowledge, there's no good way in native JavaScript to listen for connections. In HTTP, the client opens a port, sends a request, and receives a response. You could use the XHTTP or similar class to make a request but there's no good way within a normal web page to create a server on the other end that would listen for requests.
Given that, I know that Flash provides a socket library that allows you to listen for connections. (I imagine Silverlight does this as well, though I haven't researched it.) If you were to create an object using either of these technologies, you could listen for connection requests from any client (assuming that you're not behind a firewall or some other connection-filtering device), maintain an open socket and send whatever you want over the wire.
Summary:
Probably can't do this in JavaScript/HTML/CSS.
BUT, you could pull it off in Flash or Silverlight.
If the browsers are behind firewalls you can look at using NAT traversal.
Protocols like STUN and TURN are used by WebRTC to do this.
This web site has some nice examples/tutorials HTML5 Rocks
Short answer: Nope. Not possible.
Long answer: You could write a signed java applet that implements a web server in each browser. Then browser "a" could talk to browser "b's" applet (don't' close that tab!). You would then have limited access to the others browser state in this way.
Similarly, you could write a plugin/addon that could accomplish much of the same thing.
The real question is why would you want to do this? what are you trying to accomplish? Answer that question and we might be able to come up with a solution.
Yes, they could, but they would need to be designed to establish the connection (or would need to have a module that does it).
Even if I'm wondering why would they need to..
Flash - Stratus. New stuff in latest flash that provides P2P connections.