I have a website that manages realworld tabletop games via a php, jquery, bootstrap and mysql setup.
It has been running very well for a number of years, but I am implementing a team game concept, which allows 2 "captains" to manage the pairings at the same time. The page itself does what I want it to do when one captain does all the data entry, but it is not really optimal for both to be doing it at the same time.
Once both players for a game have been selected the row turns green
The goal is that as a Captain selects a player from a drop down box, it should somehow update the other captains screen and vice versa.
Should I have some kind of timer going, and every X seconds refresh the page, form, etc? Has anyone done something similar to this in the past?
I am thinking of having a table in my database with each field on the form, and when it was last updated, then I could loop through the table and only update the most recent ones, but I feel this could be an extra layer that just may be over complicating it.
Any pointers would be appreciated
Refreshing the whole page is definitely possible, but I wouldn't recommend it.
You could execute an ajax call for every x second with setInterval(). Requesting all data from the server and see if everything is loaded. You also would have to send the new data back to the server when the player changes a field.
A better approach for this would be the usage of sockets. They synchronize data across different browsers (almost) instantly. Without the need to constantly request data from the server.
You can take a look at socket.io for more information. This is a javascript package to make the implementation of sockets fairly simple in javascript.
Related
My website needs to display a dashboard (made of a datatable) on a webpage, in which the data will evolve really quickly (1 to 2 seconds). The data are received from a rabbitmq message queue.
I have successfully achieved it with Dash. Everything works well, but I have one major problem. Dash seems to be really slow when there is a huge amount of data (approximately 300 columns and 5000 rows in my case) that are regularly updated.
As far as I went, I think that the major lack of speed comes from the fact that the values pushed in the datatables are in a dictionary and not dynamic (not an in-cell modification), so all the javascript loads slowly and is not that stable.
Which leads me to this question: what would be the best way to achieve the goals mentioned above?
I thought that using Django and creating a custom javascript datatable could do the job but I would like to get some advice and ideas before starting to code that (really) time consuming solution.
I have a webpage that's for a fund raiser, and I'd like to update the amount raised live. So if a user is looking at the total raised, and somewhere else another user donates, then the first user would see the amount tick up and change to the updated amount.
I have a CouchDB for a database and Lambdas using Node.js running. How can I set this up?
It's a well known software development pattern. It's usually achieved by using "push" or "pull" approach.
In a "pull" approach a client constantly asking for data from backend. In your particular scenario it could be a timer on a page that at specified interval polls server for data and updates page if needed.
In a "push" approach backend "pushes" changes to client(s) when they become available. Web sockets would do the job in your particular case but implementing it is much more complicated than a "pull" approach.
I've done plenty of web development at a pretty basic level, and usually just local pages to be called from shared network drives.
Here is where I'm stuck:
I am attempting to build a simple application for work where other leads and I can open a local html page from our shared drive, and add/remove employee names to different tasks, so we can keep tabs on who's doing what.
The tasks are the same every day, just hardcoded titles on sectioned out divs.
Problem is, I can't figure out how to make it to where changes I make will populate for other people with the window open (considering this is just a local page and not a live environment being hosted on anything).
For the general design, I've toyed with hard coding all the employee names under each task in hidden div tags, with a bit of jquery to make the div visible when that worker is assigned.
I have also toyed with appending data to the existing tags using .innerHTML.
Still have no idea how to make this live so we can see each others changes.
Can you point me in the right direction?
I've figured it out. It may be a bit on the lazy side, but i'm just setting the HTML page to auto refresh every 5s. The data displayed will pull from a notepad doc that leads will be able to update and save.
I am assuming that you just want your peers to be able to see the changes your making live? If so you need to use Ajax. You could set it to ping the server every so often to update on the fly. I'm still quite uncertain as to whether or not that was your question, but if not please elaborate or post your code so I can help further.
I am trying to write a change listener based on NodeJS or PHP. We have a huge database in MSSQL server. I want the change listener to be listening for a change in database for example a specific column changes in database and the change listener gets the information of that particular row that has been modified and than perform operations on it. I am not trying to make a real-time application for the users. I am just trying to log the changes of one local database in an remote database and I am require todo it in NodeJS or PHP. You can see the image i am posting below.
http://i.stack.imgur.com/c3jD6.png
The part That I totally Understand
I know that what I can do is make a request to database every x amount of time. I can use sockets or long polling etc. (NOTE: Please correct me if I am wrong)
The part that I dont understand
How I will be able to get only that particular row that has been modified through sql query? (NOTE: I can just get the data from that database, I am not able to modify anything in database). Database is so huge I will not be fetching all the rows again and again. I have not idea on this.
Note
I am not doing any replication. What I am actually doing is monitoring a column in SQL server for changes and according to that change I perform certain operations in Remote database.
You cannot practically detect changes. Only SQL Server can track changes, and it exposes this tracking via Change Tracking or Change Data Capture. Your app, completely irrelevant of the access technology used (C#, C++, Node.js, ruby or whatever), can then interrogate the change tracking infrastructure and learn what rows have changed since last time it checked. Do not try to roll your own in-house developed change tracking mechanism, be it by triggers or 'changed_at' column or whatever. Many braves give up the ghost trying, save the headaches. Use the built-in off-the-shelf technologies for this task (linked above).
You say 'I am not able to modify anything in database' then the answer is simple: you are doing a fool's errand. Is impossible to detect changes w/o changing the database, is simple as that (comparison methods need not apply for any significant size). If they don't let you change the database (and enable one of the change tracking methods) then simply move on to a different project.
I am working on an app that has a javascript interval timer. I would like the timer to run on a server then I would like to grab that time on multiple devices on click.
Ex: Countdown Timer to be displayed on a large screen in a gym (this is coming from the server). I would like users on mobile devices to be able to capture time and record it in real-time.
If the timer on the big screen said 10:35 when I push the button on my mobile device I want it to grab 10:35 and put it into an input field.
I have the timer code figured out. I just don't know how to get the time that is displayed on the server to the other devices.
I know that this is a very general question. I am just wondering if it is possible, and if someone can point me in the right direction.
Thanks!!!
If you are using javascript/using node.js...you can use websockets to synchronize your timers in real time.
here is a link to a good tutorial :-) http://www.youtube.com/watch?v=pNKNYLv2BpQ
Hmmm. This is a particularly difficult problem given the intricacies of keeping time in sync across multiple devices.
Here's the architecture I'd suggest:
The server serves an HTML document to the clients that contains three timestamps: the start time, the end time, and the current server time. This could conceivably be fetched over AJAX.
From the current server time, the client can calculate its current skew and display a countdown timer matching the server ("big board") using client-side Javascript.
A button could then grab the value of a timer and populate the input field.
Here's a pretty similar question.