Hacker News new | ask | show | jobs
by jasonl99 3412 days ago
Author here...Well, I started down the websockets path because of how awesome I found crystal to be. I wasn't intending to do this a few months ago, it just sort of took on a life of its own :)

The framework as I've written takes state into account; in fact it was/is a design goal. There are three types of server objects currently - WebObject, StaticBuffer and DynamicBuffer. A WebObject stays instantiated on the server even when no users on viewing it (at some point it will be garbage collected).

At any time, rendering that object will produce the exact representation as seen by someone who has viewed it and been updated with websockets. In fact, the card game is a good example of this. Start a game, draw a few cards, start another game, and then go back to the first. It'll be in the same state you left it in, complete with the events that occurred while you were gone. This was one of the top goals.

DynamicObjects are just arrays of WebObjects in a configurable buffer - think of a list of sports scores, where each item handles its own update.

StaticObjects are an array of simple strings of html (think of tail to view a log file).

1 comments

ahhhh! Okay, yeah then that is super awesome and very impressive. You definitely should highlight/emphasize that more in the piece then. Cause that is super exciting, and the ideal way to build/have things work. FRP reactive streaming stuff, as the buzzwords go.

So next up, how do you handle conflicts? Two users write to the same thing at the same time? Great work!