screwgoth / live-location-tracker

May 2018 Python Pune Hackathon project : Live Location Tracking using Mobile GPS Logger
31 stars 10 forks source link

Create WebSocket using Django-Channels that calls location API when any update Occurs #22

Closed chetanzope closed 6 years ago

chetanzope commented 6 years ago

In this, we created a simple WebSocket connection between client and server. We used Redis as channel layers. CHANNEL_LAYERS is the transport mechanism that channel uses to pass messages from producer to consumer. In CHANNEL_LAYERS, we’ve told Channel where to look for our channel routing. Channel routing is a very similar concept to URL routing: URL routing maps URLs to view functions; channel routing maps channels to consumer functions. -- This is about what to use for WebSocket.

chetanzope commented 6 years ago

After this, we used an action called subscribe. Subscribe action is used to notify the client if some action(Create, Update, Delete) happens. So whenever we get the locations from GPSLogger App, it notifies the client via message(Redis-Message). This message is generally a JSON response in which we got the updated lat-long and we show them on the map.