pubnub moduleMonkey Programming Forums/Monkey Programming/pubnub module
| Following from my previous thread where someone was talking about networking in monkey, I spent a little time today getting pubnub working in html5 and flash!|
See the demo here:
It was incredibly straight forward, and doesn't require anything special to be done to your project files. The required pubnub source and dom elements are attached at runtime.
You can download the example + module here:
I don't really have time to continue development on it and just wanted to have a try. Is anyone willing (got the time?) to continue where I left off and implement this for the other targets?
[update] I tweaked the demo to use hard coded font colors (seperate font for each color) and not apply any SetColor ... so it now shouldn't run like a dog :D
[update again]I have now added a flash target to the module! You can check the example and switch between html5 and flash versions...
| nice demo,|
it says on the website 5 million messages per month are free ^_^
the messages are held on the pubnub servers?
Yup 5 million free which is pretty damn good and no need to pay for a server as its stored on theirs :D
| I like it and will use it! |
| Updated with a flash target... |
| Thanks skn3. Just what I needed. |
| Excellent work! That editor is so nice and fluent... Any chance you'll make that into a library? :) |
| 5 million messages can be used up very quickly. Just do the math.|
But thanks for the module. It is always good to have more possibilities.
| 1 thousand people could play for 39 minutes a day at 70 messages a minute (1 a second plus 10 additional). Yeah not a huge amount, but fairly good for messing around with! I wonder what the limit of number of accounts is, you could potentially setup a webserver to list running games and then divert connecting users to appropriate pubnub account keys, each with their own 5 million message limit. I dunno if that breaks any terms/conditions they have though...|
Thanks for comments btw, now any brave soul want to tackle one of the other targets?
A decent server would cost you about minimum £100 a month plus then the additional time of coding a steady infrastructure that can scale... lets say minimum 4 months (probably more like a 8-12) of development? starts to work out less expensive then you first think...
There is another service http://www.pusher.com that offers a more competitive rate! I wonder how hard it would be to write a "dirty" pubnub server in node.js or something! (and then swap out the destination in the library)
Excellent work! That editor is so nice and fluent... Any chance you'll make that into a library? :)
Do you mean the chat pane and input box? take a look at the sample code its fairly straightforward, nothing fancy.
1 thousand people could play for 39 minutes a day at 70 messages a minute (1 a second plus 10 additional).
I get then 81.900.000 messages in on Month.
1000 people x 39 minutes/day x 30 days x 70 messages/minute.
| Whoops I miss-calculated!|
So roughly twenty people could play for 2 hours a day on 70 messages a minute.
(5,000,000 / (70 * 60) / 2 / 30)
| This is really cool! :) |
| Indeed. They lowered this to 1 mio. messages free per month. What does "message" mean in this context? |
| oh cool they have a pay as you go method now... much better!|
A message is any message pushed to them or pushed from them to a user. So that means if you had 250 people subscribed to a channel and 1 message was sent that would count as 251 messages. 1 used to send to pubnub and 250 to send that back out to all of the subscribers.
So in this context.. if I send a message on the demo and 4 people are connected that is 5 messages.
The pricing model is not that great for indies but I guess their new scaled pricing is a bit better!
| Nice! I did notice on HTML5 (Safari) I don't see any chat history, it loads the history in flash version. |
| Yeah I noticed that intermittently. Maybe Xaron could nail that bug, I'm sure its probably just a typo or something... |
| Ah well. Got it to work under Android. :)|
In Java I just do (in a loop):
JSONObject o = response.getJSONObject( i ); String s = o.getString( _jsonKey );
| if you force communication to be string based (eg convert json to string before sending) then you could rely on the each of the targets own json implementation to then translate back to json object?|
or have I misunderstood?
 this could also help?
| Will this be combined with mnet or be a standalone module? There are multiple topics around the forum about this and it started to be hard to follow all of them. |
| Xaron is combining this into mnet :D |
So the next version of MNet will have http requests and pubnub.
And BTW: I got my problem solved! So messaging from Android to HTML5 and back works (in between of course too)!
| That is killer stuff :) |
| Cool, what was the issue? |
I still think it would be cool to write a pubnub server to bypass message limits! Maybe I'll write one in nodejs when I find a minute..... When!