Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recognise which tab made the request

This question probably doesn't have an answer. But, I thought I'd give it a shot. I wrote a great one-page application. When the application starts up, the open tab "registers" itself with the server, which stores is as an "active" tab.

If user A changes XYZ in the workspace, every tab opened on that workspace, by any user, receives a notification that XYZ was changed. That triggers a reload in the clients, which will magically be updated. At the moment, I am doing this by polling. However, when it all works I can use things like WS or Socket.io to make things even faster.

PROBLEM: every tab receives the notification. Even the tab that instigated it in the first place! (as a result, an already-updated screen gets updated)

I somehow need the server to know the tab ID of the tab making the request. Remember that a user might have 5 tabs open: if they change XYZ, all tabs should receive the notification, EXCEPT the one that actually triggered it!

At the moment, I am passing the workspace ID for every Ajax request ( a user might be logged in, and have access to several workspace at the same time).

  • Solution 1: append both workspace ID and tab ID for every request
  • Solution 2: only use the tab ID for every request. The app will work out the workspace ID from the tabID (which knows which workspace it belongs to)
  • Solution 3: ????? (Something that I am missing?)

Any ideas?

like image 988
Merc Avatar asked Jan 15 '13 07:01

Merc


People also ask

What is a search tab?

Google is rolling out a new 'Tab Search' feature that allows you to search through your list of open tabs among all open browser windows to find a specific page.

How do you check which tabs are open?

Tab Search doesn't require any setup or opt-in. It appears as a simple drop-down arrow in the top tab bar. To begin, click the arrow button or use the keyboard shortcut Ctrl+Shift+A (Cmd+Shift+A for Mac). You will now see a vertically scrollable list of all the tabs you have open in Chrome.

How do I get the tab name in Chrome?

Just click the circle next to your tab group to enter a name and pick a color. Right-click the colored circle next to the tab group you wish to name. Enter a name for the tab group.


1 Answers

Instead of having the server worry about which tabs to send change notifications to you could have the tab that initiated the changes ignore the notification.

Two ways to do this come to mind:

  • After changing the content a tab will ingore all notifications for a brief period of time. (This will work fine unless changes on multiple tabs happen in a short amount of time.)
  • Have the tab create a "change id" that it sends to the server with the changes to xyz. The broadcast change notification contains this id and the sending tab recognizes it as the one it sent and ignores it.
like image 74
alexwells Avatar answered Oct 13 '22 17:10

alexwells