real time gps reall needs database? - javascript

I'm working on a project that involves real time tracking. I'm using html5 geolocation API and I'm stuck where users should locate others. Mine is not storing the lat,lng of the user in a database. Now my question is can I continue my project without database?

Yes you can. When you receive the GPS data, you could directly send it to all recipients. Therefore, you dont have to store it in a database. To be able to create channels with clients that stay open over a longer time, HTTP wont work, you will have to use WebSockets instead. A famous implementatoon for nodejs is https://socket.io

Related

AJAX - How can I build a notification system, that is constantly getting updated, without slowing down my website too much?

I am a beginner to web development, and I am trying to do a notification system with AJAX and jQuery.
In my web application, I have a comment system where you can mention another user. After a comment mentioning a certain user has been written, a new entry on my notifications table will be added, containing the comment, the id of the user who commented and the id of the user(s) who will receive the comment. After the notification is stored in the database, I want the person that was mentioned to receive the notification.
To that effect, I decided to use AJAX. Using the setTimeout() method, I am sending an AJAX request to the database every 2 seconds, and with that, I can display the notifications visually to the user that is meant to receive them.
My only concern is that this will slow down the site once I connect it with a server.
So, I was looking for a way that would allow me to implement a notifications system without slowing the site too much, since the one that I am using currently doesn't seem very efficient.
I would appreciate any help.

Sending RealTime Notifications Based on Location in NodeJS

I’m building an app with some location-based requirements. One of the requirements is to send the user a notification whenever the user is at a specific address (think of it like how the Apple Wallet app sends you a notification whenever you get close to, say a Starbucks location).
How would I go about building this kind of functionality? I’m aware that this will require using WebSockets. But, like, how would I do this exactly?
Do I just have the client send his geo coordinates to my backend every time it changes, then compare that to a desired destination saved on a database? Or, is there a better way?
Thanks.

run query automatically after a data inserted to MySQL database

I'm trying to make a web based tracking system with a GPS that can be controlled by sending SMS.
How my system work:
When user clicks a button to know the GPS location, the system send an SMS (with certain format) by SMS gateway to the GPS device. The GPS will reply with its coordinate by SMS too. After that, the location information of the GPS such as latitude, longitude, and etc will be taken from the SMS with a function and a trigger (I already make it and it works) and the data will be inserted automatically to a table named tb_history.
I want to display the newest location data that just inserted to the table with this query:
SELECT * FROM tb_history WHERE tb_history.`id_gps`='1' AND tb_history.`date`='2014-04-24' ORDER BY tb_history.`time` DESC LIMIT 1;
my question is, is there a way I can run this code automatically after a data just inserted to the tb_history? my teacher say that maybe I can use a javascript that always refresh the page and stop refreshing if there was a data inserted to tb_history???
I really need an example to understand it...
I forgot to mention that I made my system with PHP and javascript
sorry for the bad english and Thank you for those who gave me the answer...
Use mysql trigger for this purpose http://dev.mysql.com/doc/refman/5.1/de/create-trigger.html
From your edited question I would guess you are confusing the CGI-script on the server that you implement in PHP with the webpage, generated by the PHP-script on the server and, loaded by the client that should be using Javascript to get an update from the server when the SMS returns from your application on the telephone.
Mister Henson gave you keywords for two good google searches about how the Javascript can learn about when the returned SMS arrives.
Two hits on the google search lead to this site:
What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?
How do I implement basic "Long Polling"?

How to help protect for irregular internet connection in a Backbone application? Is there a solution like in Meteor?

I am building applications that are used on a touch screen in an educational environment. The applications gather data from user input. The data is then send to a server. There are multiple units, and whilst exact synchronisation is not paramount, the gathered data (along with other data collection from another source) will be combined and distributed back to the touch screen applications.
The applications are being build in Backbone with initial data loaded from a single JSON document. The JSON document is parsed from a remote MySQL database, which is downloaded (along with assets) on initialisation.
Whilst when possible the app should send new data back to the remote mySQL DB as soon as it is gathered, this may not always be possible and I need to collect the data so as to send it when I can.
My first thoughts are that storing everything in localstorage and syncing whenever possible (clearing the localstorage each time a successful sync takes place) is the way to go.
Over the bank holiday weekend, I have been playing meteor.js, and I think that maybe if I write my localstorage solution I will be reinventing the wheel, and a tricky wheel at that. It seems that Meteor.js has a way of mimicking a database offline, in order to fake instant updating.
My question is: How can I use a similar technique to add some offline protection? Is there a JS framework, or backbone plugin I can utilise, or a technique I can tap into?
You can use Backbone.localStorage to save your models and collections to the local storage, while the connection is offline.
Detecting if your user is offline is as easy as noticing that your xhr requests are failing. (https://stackoverflow.com/a/189443/1448860e).
To combine these two.
When you suspect the user is offline (an ajax request to your backend gets no response), switch Backbone.localStorage and store everything there. Inform the user!
When the user gets Internet connectivity again, save any changes from localStorage to the server. Inform the user again!
Voilà!

Creating my first Mobile App and connecting it to a database

I have to create a Windows Phone 7 app as part of a research project. The app needs to:
Allow the user to login by connecting to an sql server database (stored locally for the purpose of this project)
If login successful, return a list of products associated with the user (i.e. in product table where UserID=x)
User can click on an item in the list, and then add photos for that item. This can be done offline as well (using HTML5 offline storage)
When an internet connection is available again, user can click 'Upload' (or automatically synced, but not necessary) and the images are all uploaded to the Images table with the correct ProductID as Foreign key
Since this is the first time I am doing any mobile programming, I am not sure what is the best approach. I am especially unsure of how I am going to connect to the database. I'm not really interested in learning Silverlight, so the app should use mainly HTML5 and javascript, I also am looking into JQueryMobile.
I have already installed PhoneGap and am trying it out, but my main concern is how to connect the app to the database as I am having trouble finding the 'proper' way of doing this e.g. using some kind of web service or directly through javascript (read it can be done but is not recommended). If anyone could recommend or suggest a good approach of doing this that would be great!
SqlServer is only available on the phone via LinqToSql which you need to expose via a service or a DAL. I dont think that its possible to make calls directly from Javascript to LinqToSql on the phone.
If you're not set on the idea that the DB needs to be on the phone, you can just make service calls via ajax to a server and access the db that way. I recently did a blog post exposing a db via a WCF Data service and consuming it on the phone. It doesn't cover calling it via ajax but should help get you started.
http://www.ritzcovan.com/2012/02/building-a-simple-windows-phone-apppart-4/
If you want to store data within the WP7 database, use the PhoneGap storage APIs.

Categories

Resources