I thought that Firebase would be incredibly useful as a rapid prototyping tool, but I'm now thinking of using it as a backend for a couple of apps I'm bootstrapping and doing away with servers altogether. iOS support and other interesting features are in the pipeline, and it's already an incredibly compelling platform.
The only thing missing for me right now is webhook support.
Or am I just really slow?
I'm a front end developer and designer, so I can throw layouts together pretty quickly. I now use Typecast[1] to set a basic mood and find a header and body font, then for simple sites like this I skip Photoshop/Fireworks and do the ‘layout’ in the browser.
[1]: http://typecast.com/
Picking a technology for the 2-way comm was tough back then, since Layers only worked on Netscape and IFrame was IE only. I ended up going with a frameset and zero-height frame at the bottom of each screen. When you input your move, it'd submit a form on the frame and update the state on the server. And the frames would periodically poll to see if the opponent had given his move.
Once both moves were available, it'd run its little Mortal Kombat pixel art animation and crush the opponent's scissors with its fist. It was start of the art at the time. I hadn't ever seen anybody do real time web stuff at that point.
As I find happens with most "build something silly while slacking off at work" scenarios, we ended up shipping it a few months later. One of our products looked like it could actually benefit from the ability to real-time update one of its components, so I tore out the fighting and used the RPS comm stuff.
Can you please comment on what kind of stack you've got going on? Is this operating on websockets?
The app's 100% JavaScript, served from a static server, and backed by Firebase. https://www.firebase.com/ You include their library and create a reference to any point in your "Firebase", which is essentially a live JSON store that each client subscribes to. Clients can push data to the store and declare callbacks that fire when data changes at any given endpoint. Changes persist in near-realtime between all connected clients. It is very neat.
Is it down?
Edit: Reloading the page (with /?random) either generates a random room for me, which is no use when I want to play a random opponent, or does something in a flash and then asks me if I want to play again, meanwhile still displaying a 0-0 score. When I click play again, it keeps saying "waiting", though in the right bottom there is an opponent connected. I somehow doubt it.
I need to dust off my game theory textbook.
I need to work out how to store and validate scores in Firebase to prevent cheating (which should be possible with their security rules, I think).
1. Clients notify server they want to play a/another game
2. Clients both pick their 'answer' (spock/lizard/rock/...)
3. Server only tells what choice the other made once both players submitted
4. Server computes who wins, and updates scores accordingly
This does require a stateful server, but I don't think it's possible to make it cheat-proof with only clients.I think I can configure Firebase to validate scores based on some precondition (i.e. 'only allow this value to be increased by one if both players have chosen and declared'). Then clients would reset their choices immediately and scores would be 'locked-in' until the next victory condition is met. That will prevent basic attempts to cheat, but I need to look into the docs to see if I could be smarter about it.
If there is no "random opponent" to be found within say 20 seconds, you could fake the "random oppenent" to be a program that is random-rpsls'ing with me.
Nice Spock intro animation!
http://en.wikipedia.org/wiki/Rock-paper-scissors-lizard-Spoc...
EDIT: As nthitz helpfully points out, it wasn't invented by Sheldon, or anybody in Big Bang Theory. Let's say it was popularized by Big Bang Theory. Bazinga!