rails 3.1 realtime update feature - ajax

I've seen many sites that their messages feed is keep sliding down incessantly.
For example: the previous version of twitter and now the foursquare. How to do that?
Moreover, I also want to know how to implement meetup's RSVP instant push in rails, they update it by seconds?
Thanks.

These companies will most likely be using realtime web technologies. Here are a few you could use with a rails and/or ruby applications:
http://juggernaut.rubyforge.org/
http://faye.jcoglan.com/
http://cramp.in/
https://github.com/raggi/async_sinatra
http://postrank-labs.github.com/goliath/
You could also use Pusher (who I work for) as we have a Pusher gem. If you do this it means you are not hosting the realtime infrastructure yourself.

Related

Real time update front end data comming from laravel

Orriginal question
I'm relatively new to PHP web development and Laravel and looking for a good way to update my front end data real time. I'm developing a simple web based game what can be played with multiple players. When a player did his turn, the data in all players front end need to be updated.
I know there are 2 ways to do this
Websocket(s):
Laravel does not support websockets by default what means i need to use a third party service like socket IO. As i just want to run my application on a "normal" web hosting, this is not an option.
push messages:I can also use push message with a service like Pusher or firebase but this option has restrictions when using a free account OR i need to pay after i need more than x resources. This is not what i prefer.
Is there a way to update the front end data without using 3rd party services OR installing a 3rd party application on the server?
Serparated from the previous question, i'm curious if push messages (and the eventually suggested solution) works also for mobile browsers.
Question update:
After the comment of Yeeooow i noticed that i needed to ask the question different. Maybe i need to explain my "problem" a bit more and ask for the solution for this.
In my game a player decides when his turn ends and he can trade a card with other players. In both cases the data need to be updated for all players. I use Vue for the front end and Laravel for backend. What is the best practice to achieve my needs?
you can use websockets with laravel like Ratchet
i had used it with laravel, but you can't use it on shared hosting because you need to import ZMQ and open some ports and that's is not available on shared hosting it is available on VPS or dedicated hosting

Is it posible to broadcast Laravel events to Socket.io without Redis?

Good evening, programmers!
I have an issue with my program. There are several restrictions to my environment, so I cannot use Redis in it as well as Pusher. But I have to build realtime application. So, my very last alternative is socket.io.
I want to use Laravel Broadcasting System to notify my socket.io on events and after that - notify frontend part of my application with this events.
How could I do that and may be are there some packages to do this job? I will appreciate for any help!
Sure you can. Memcached might be something for you to look into.

Web Api Versioning for multi tenant saas application

I currently developing a multi tenant saas application using asp web api. The api will be published and consumed by 3rd party application. My question is regarding versioning. I'm struggling to find a way to build the api so that when i updated the api, it wont make 3rd party app that uses the api to stop working. I've seen many api append the version no into the url. But that means that i have to keep old version api until all 3rd party app has been upgraded and use the latest api. I also have to update the old api to adapt to database change. That seems like a lot of work. How do big companies solve this problem?
There is no easy way around this; you will have to do the work to support old versions as long as your customers are using them.
Adopting a RESTful approach in the first place, and avoiding 'fat controllers' may help reduce the pain but beyond that every old API call will need to call into your new service layer and will need to return the results in the format your clients expect.
I'm struggling to find a way to build the api so that when i updated the api, it wont make 3rd party app that uses the api to stop working. I've seen many api append the version no into the url. But that means that i have to keep old version api until all 3rd party app has been upgraded and use the latest api.
No one, absolutely no one has researched, built, versioned and maintained APIs more than NetFlix - not externally but internally. They used explicit versioning (e.g. URL) in their APIs and maintained multiple versions of the same API and got their clients move along by providing incentives (new features). This is also something that can be built into your SLA, e.g. you guarantee support of particular version only for 12 months.
This is a very controversial topic and you will hear people suggesting implicit versioning (e.g. by media type etc). Feel free to listen to those but pragmatism favours explicit and purism favours implicit.

Implementing chat in Rails

I am trying to implement a chat module in my rails application. I looked into this railscast Faye tutorial. More through the tutorial, Ryan mentions about broadcasting the messages but what I want is more like private conversations between the clients instead of broadcasting.
Is it possible to do that through faye? or is there a better way of implementing chat in rails?
There is a gem that handles the autentications for you for faye, so users can only listen on channels you subscribe them to. There is also a railscast talking about that gem.
https://github.com/ryanb/private_pub
I don't know much about Faye, but assuming the principles are the same as with something like pure node.js and websockets, you'd divide the channels that can be subscribed to down into as many chats as there are occurring, then you'd require some sort of authentication before a client can subscribe to that channel, of which there are numerous approaches, as with most authentication systems (e.g. shared secret, username/password, challenge/response etc).
I have used Ryan's tutorial on private_pub to achieve an a Gmail like instant messaging feature. It's actually not very complex. See how I achieved it in this tutorial http://goo.gl/l3e8zN

Handle skype message using Ruby

Is there any library that allows to handle Skype messages using Ruby?
Take a look at this: http://rubyforge.org/projects/skyperapper
If you are using JRuby http://skype.sourceforge.jp/ might be a better option
For the public API doc: http://developer.skype.com/accessories
You can use the RestClient gem and the tropo.com service to send and receive Skype IMs. See the documentation for their REST api here:
https://www.tropo.com/docs/scripting/message.htm?search=skype#anchor
They're currently not charging for the service that sends/receives instant messages.
There are currently two ways of accessing the Skype network in a sanctioned manner. The first is the Skype Public API, which requires talking to the official Skype client running on a local machine. The other is SkypeKit which I am led to believe has a very restrictive agreement attached to it.
SkypeKit for ruby is available as a gem here.
The following is historical only; Skype no longer supports the Public API for their client. I have also been working on a Ruby wrapper around the Skype Public API. It's far from finished at the moment but supports Windows and Linux currently (OSX should be easy to implement as well, however I currently don't have a Mac) and allows you to connect and send commands to Skype manually. Long term the entire API will be wrapped.
In the interests of full disclosure, there seem to be a few other projects hanging around too, however they seem to only target a single platform and the ones I found seem to be abandonware at the moment.
libpurple have a plugin for Skype, but this is not easy to Setup.
Unfortunately, Skype protocol is closed & encripted, so there are no good libs out there.

Resources