Noobhub - Free Opensource Multiplayer And Network Messaging For Coronasdk

I don’t know what to say, for some reason now it works just fine… I’m starting to think the problem was somewhere on our server side, but of course the server guy says everything is just fine, but we all know that until I’ll show him hard evidence of something wrong he’ll go on saying it’s fine…

Aside from that point, I would still love to know how I can see the log messages generated by noobhub for future use :slight_smile:

well, make sure that in file node.js verbose is set to true, and then rerun server

$ nodejs node.js  

it will print debug output straight to stdout, there you will be able to spot if smth is wrong.

also, one of the developers had such case: he was using forever.js to run Noobhub.  foreverjs was writing all output to text file logs, and verbose was set to true by default. his server ran out of space and Noobhub could not start (foreverjs actually, Noobhub doesnt rely on filesystem).

Cheers!

Well, seeing as of right now I’m only in the testing phase of the project, our server shouldn’t have a problem with the size of the log, we had log files generated by other projects that were 10 gigs in size. yes, it managed to kill our server in the end, but I don’t think we’re there yet.

Again, I’m must be missing something in the whole process, since in the node.js file, which I will call “the server” from now on so we’ll know what I’m talking about, I see no where a refrence to “stdout”… the only thing there is is this function that writes the log:

\_log = function(){         if (cfg.verbose) console.log.apply(console, arguments);     };

does that means the log would be written only while the console php file is run? or there is no connection to one another?

Since what I’m trying to debug is not the php client, but my corona client, where are the log lines for connections coming from corona are being saved?

I’m sorry I’m so hard headed about this issue, but I’ve never dealt with this type of service before I don’t know my left from right…

Hi overtorment,

I am a starter of corona from hong kong (so my english may not be very well) but i am willing to make a multiplayer game by NoobHub.

However after reading the files i am confused how should i start with.

Could u please give me a brief introduction of how to use your codes?

Hi overtorment,

I am a starter of corona from hong kong (so my english may not be very well) but i am willing to make a multiplayer game by NoobHub.

However after reading the files i am confused how should i start with.

Could u please give me a brief introduction of how to use your codes?

Hey there again overtorment, good news!! I was able to battle this out with the server guy, he was “kind” enough to give me permissions to view the server space where the script was run and then, finally, get access to the log file, I’m sorry this took so long, but that guy is impossible, can’t have him killed, yet… too much power in one persons hands, always a recipe for trouble.

Any way, since I wasn’t able to get direct access to the log file until now (he set up an auto system which took my modified node.js file from a specific folder and copy it to the right place, closed the old process, and started the new one, it’s a drag…), what I have done it a type of “internal/external” log, where if a specific user connects, lets call him “admin”, then any message or connection being passed to the hub makes the hub send the admin any information I may need, like who the message from, to, their socket status, if exist and so forth, which helped for solve the problem I had, which was a simple lowercase/uppercase problem, like most problems in life…

Thanks again for all the help and the great work you’ve done on this code.

overtorment - Thanks for this! This is great example code. 

Question, have you considered leaning on REDIS to make this more scalable?

@coolromin yes it looks like a network latency lag. This is where lag-compensation and prediction algorithms should be thinked of.

Vavle has nice tutorials on how they do it in their multiplayer games (I posted the links above).

Easiest solution is: when client receives event, place it not on the same coordinates where it originated, but calculate new ones based on the time it took the message to travel through the network (tens to hundreds of milliseconds, it depends).

I posted some diagrams of how my algorithm to determine actual network latency between 2 clients works on the 1st page of this thread.

@tfargason yes credentials look correct:  https://github.com/Overtorment/NoobHub/blob/master/client/lua-corona/main.lua

Ive just checked, server is up and running. You can try downloading example app from github, and check if it works.

Maybe you’ll have to update Noobhub client library…

@r.delia Good job! But anyway, I think Noobhub should be used for publish-sibscribe messaging only, and should not handle heavy backend calls. So I suggest you to do backend stuff via plain requests to your scripts (php, python etc) to do stuff with database, and leave Noobhub only for messages routing.

First of all, this is amazing and just what I was looking for, thanks for the hard work overtorment.

I was able to run node.js from terminal in OSX and communicate with the sample app running on the corona simulator, but when I try to test on an actual device and send data to the server running on my mac I get nothing. Also worth noting, I’m as green as they come when it comes to networking. Any idea what I could be doing wrong?

@marble68  yes I have. I considered Redis, but at the moment I dont have tasks which require such scalability.

@Jorge Sanchez

May I suggest that you are using loopback addres, such as “localhost” or “127.0.0.1” ? Also, might be something with Firewall.

@sochunhong1 reat the Readme file on github.

Cheers!

Dear overtorment,

“Once somebody needs to find a gaming partner, he posts a message to the lobby channel, like, ‘who_wants_to_play’.
Every client on lobby who is up for a game, answers ‘i_wanna_play’.”
 

How if some clients get in to the lobby after the hosts sent  ‘who_wants_to_play’? How can they join the host?

Thanks,

Jason

I would imagine that a list of games would be visible in the lobby channel that are available for joining, but that might require modification in Noobhub? Or maybe a timer.performWithDelay function that continually publishes “who_wants_to_play” in the channel until the game is officially closed from additional players joining?

I’d like to know the answer as well.

And overtorment, if you can advise on what sort of topics I can read up on to better understand how Noobhub works, that would be much appreciated

Hey overtorment!

What database solution would you recommend me to use alongside noobhub? And if u can point me to any script or tutorial on how to use it with corona?

Thanks Again!

I would recommend CouchDB (its a key-value storage) because of its REST interface.

And as I said, I would not recommend hooking it up with Noobhub. Your clients (on Corona-Lua) should talk with it.

Thanks for your suggestion…I really appreciate your quick replies and useful guides/helps.

What about Sqlite which is supported by corona? Oops sqlite support open database from url :stuck_out_tongue:

Anyway, I would very apreciate it if you give me an example on how to use couchDB with lua. (I am very new to lua and apart from using NoobHub for networking, i haven’t used any network functions of lua so i have no idea abou it.)

Thanks Again!

I found a lua framework for couchDB HERE ,  I really don’t want or need to make stuff very complicated, i will be using couchDB to login users and update their scores etc, So do u recommend using this framework or it is better to go without it?

Sorry for asking so many question :d

overtorment you’re doing an awesome job with noobhub! just sayin

Anyways, I’m working on my first online game and I don’t know how to set up an amazon ec2 server with noobhub. Any suggestions where I could look to figure this out or is there a simple way someone could explain it?

Can’t get the php console to work, even tough node.js is (well, was…) running just fine, untill it didn’t and made me look into the php to have some log information.

First, what I get on the php when I run it on my server:

Hello. Noobhub online.  Warning: stream\_select(): supplied argument is not a valid stream resource in /var/www/flashgames/mobile/console.php on line 52 Warning: stream\_select(): supplied argument is not a valid stream resource in /var/www/flashgames/mobile/console.php on line 52 Warning: stream\_select(): supplied argument is not a valid stream resource in /var/www/flashgames/mobile/console.php on line 52 Warning: stream\_select(): supplied argument is not a valid stream resource in /var/www/flashgames/mobile/console.php on line 52 .......

What and where the problem seems to be:

if(non\_block\_read(STDIN, $x)) {

already you can see a problem there, where “STDIN” is not formatted right for a php variable…

My search on “STDIN” on the page gave me this line:

$in = fopen('php://stdin', 'r');

So I thought to myself, replace “STDIN” with “$in” and the problem should be solved.

Of course I was wrong.

Can you give me hint in the right direction? At this point I had node.js running just fine on our server, working like a charm, today, it doesn’t, so I’ll need, or want, the console to see some messaged from it so I’ll be able to debug it.

Thanks again for all your effort!

Yuval.

Well, console connects to Noobhub, its not intended to debug nodejs code.

If the problem is with Noobhub server, php script will fail as well.

I suggest to turn verbose mode on Noobgub server, re-run it and see whats wrong.

PS. STDIN is a valid php constant pointing to real stdin.

Thanks for the replay, I was not aware of that, I was sure the php console file was meant as a way to view the log messages generated by the server running, if that is not the case, what am I missing here? how can I see the _log messages the noobhub generates? (I’m sorry for needing all this information, this is not my native language, I’m trying my best to understand what I’m doing by applying information from other languages I use to your code, some I’ve made work just fine, like sending a user name when subscribing along side with the channel name, so I could store the sockets in an associative array and not a numeral one, so I could easily send message client to client instead of client to room, which worked perfectly).

The problem I’m seeing with noobhub at the moment is not that it does not work, since I can connect to it from my corona project, but for some reason the messages sent are not reaching their destination, which worked find until 2 days ago, but with out being able to see at the moment the log messages, it’s a hard time debugging this…