Wednesday, January 19, 2011

We need an API

Me (Jeena), Mathias and Niklas talked about how an API could look, we aren't really ready but this is what we talked about: There are two JS-Objects we introduce: "Users" which is a array of User objects "World" which is a key-value store and introduces two methods: getVal(key) which only gets the value for a key from erlang and returns it setVal(key, val) which does a little bit more, it sets the value for the key in our erlang key-value store and it saves the key in a erlang list with keys which have been updated. and there is a notifyAllClients() method which loops thru the updated list in erlang, packs all the changes into a one notification package and sends this package to all clients. This is only to not to have update all clients for every setVal() call but buffer it if needed. There is one more thing, our protocol needs two different action types. One when a client wants to instantiate a game; it sends the world in JSON format and sends all functions/methods as a (JavaScript) String which we evaluate and add to our spidermonkey. Then the other would be when they want to use the functions to change the world. Cloning and Spidermonkey I was just talking to the spidermonkey developers at They say there is no way to clone a spidermonkey instance for various reasons like that there is no clone method for user defined objects, etc. And they said that we should not use their js-shell because they use it on their self for debugging and it is really unsafe. One of them suggested we could just delete a bunch of unsafe functions from js/src/shell/js.cpp Another one suggested we write our own shell with just the functions we really need and he said it'd be easy to do if we'd have a look at their shell while doing it. But I think if we use a API for saving the data in erlang then we wouldn't need to clone spidermonkey, just start up a new one and send in the js-code we got at the beginning.

Time report

8 hours