Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Noobhub - Free Opensource Multiplayer And Network Messaging For Coronasdk
Started by overtorment Mar 15 2013 03:25 AM

177 replies to this topic
multiplayer opensource net network
[TOPIC CONTROLS]
Page 1 of 8 1 2 3 »
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

overtorment

[GLOBAL: userInfoPane.html]
overtorment
  • Starter
  • PipPipPipPipPipPip
  • 69 posts
  • Jedi

Hi guys, just spreading the word about Noobhub, a library Ive built to create network multiplayer games and apps.

 

There are already several apps from different developers who happily use Noobhub in production.

 

 

 

Previous official discussion was here http://developer.coronalabs.com/code/noobhub  but who knows, maybe official discussion will move here.

Code is available on Github https://github.com/Overtorment/NoobHub

 

 

  • * Connections are routed through socket server with minimum latency, ideal for action games.
  • * Simple interface. Publish/subscribe paradigm in action.
  • * Server written on blazing fast Nodejs.
  • * Socket connections, works great through any NAT (local area network), messages delivery is reliable and fast.
 
 
Repo includes server code (so you can use your own server) and Corona lua client. More clients to come. You can test on my server, credentials are in the repo!
 
Lua code may serve as an example of how LuaSocket library works.

 

 
 
PS. First post on new forums. Hooray!
 
 
EDIT. If you like Noobhub, please give it a star on Github!


[TOPIC: post.html]
#2

Minion Multimiedia

[GLOBAL: userInfoPane.html]
Minion Multimiedia
  • Pro
  • PipPipPip
  • 41 posts
  • Advanced Member

@overtorment

I have been trying to develop a web interface to NoobHub ... All I have managed to get is a php page to connect get back 1 line then close the connection... Is it potentially possible to do something like this?

 

Also, we released our app last Wednesday for the App Store, Google Play, and Amazon App Store that uses NoobHub!



[TOPIC: post.html]
#3

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Pro
  • PipPipPipPipPipPip
  • 950 posts
  • Jedi

Has anyone had reports of socket connections not working well or not at all when users are on 3G? I know some users could possibly have issues but wondering if this is a widespread problem.

[TOPIC: post.html]
#4

overtorment

[GLOBAL: userInfoPane.html]
overtorment
  • Starter
  • PipPipPipPipPipPip
  • 69 posts
  • Jedi

@overtorment

I have been trying to develop a web interface to NoobHub ... All I have managed to get is a php page to connect get back 1 line then close the connection... Is it potentially possible to do something like this?

 

Also, we released our app last Wednesday for the App Store, Google Play, and Amazon App Store that uses NoobHub!

 

Actually, there's a php client in the repo. Its provides console  access to the channel, so you can type commands to channel and receive what's the other end sending. I use it for remote debugging on real device.

It can be handy to implement simple commands in Lua, so you can type lile. "Img1.x = 100" in console and this will instantly apply in your app (handy to fix issues on real device instead of simulator)

Could you also post the link to your app..?

 

 

 

Has anyone had reports of socket connections not working well or not at all when users are on 3G? I know some users could possibly have issues but wondering if this is a widespread problem.

 

Experienced no issues on this  yet... Anyway gona implement silent reconnect mechanism in Lua client, that should fix most connection issues.



[TOPIC: post.html]
#5

Minion Multimiedia

[GLOBAL: userInfoPane.html]
Minion Multimiedia
  • Pro
  • PipPipPip
  • 41 posts
  • Advanced Member

 Actually, there's a php client in the repo. Its provides console

 access to the channel, so you can type commands to channel and receive
what's the other end sending. I use it for remote debugging on real
device.

 

Yeah I saw that... It actually was were I started from... Was hoping to have at least a one way access to the NoobHub stream via the web... Was able to create a super fast RealStudio client that *could* be compiled for he web...

 

 

 Could you also post the link to your app..?


HT+phoenix

 

Website -- http://bit.ly/YUp7Uz

iTunes -- http://bit.ly/ZJo1tf

Amazon App Store -- http://amzn.to/ZMODM1

Google Play -- http://bit.ly/ZB4c5O

 

It is an app geared toward the security sector... We started work last June/July but was back burnered because there wasn't any good communication implementation out there ... Took about little over a month to refactor it to utilize NoobHub (and massively clean up the code)... Spent a good chunk of time with disconnect situations (the code will try to reconnect to the server if it detects it can't reach the server)...



[TOPIC: post.html]
#6

overtorment

[GLOBAL: userInfoPane.html]
overtorment
  • Starter
  • PipPipPipPipPipPip
  • 69 posts
  • Jedi

Spent a good chunk of time with disconnect situations (the code will try to reconnect to the server if it detects it can't reach the server)...

 

well then, share this code if you coded this in noobhub.lua   :-P



[TOPIC: post.html]
#7

Minion Multimiedia

[GLOBAL: userInfoPane.html]
Minion Multimiedia
  • Pro
  • PipPipPip
  • 41 posts
  • Advanced Member

well then, share this code if you coded this in noobhub.lua   :-P


 
I didn't change anything in the noobhub.lua file but I'll just give a gist of what I did ...
 

local subscribeChannel = function ( event )
   if connected == false then
      hub = nil hub = noobhub.new ( { server = serverIP; port = serverPORT; } );
      print ( "trting to connect to:" .. serverIP .. ":".. serverPORT)
   end
   
   local function testListener ( message )
      // DO STUFF HERE
   end

   if connected == false then
      print ( "trying to subscribe" )
      canPublish = hub:subscribe( { channel = ( lobby ); callback = testListener; })
      connected = canPublish
   end
end

function publishNOOB ( msg )
   if canPublish == true then
      testA = hub:publish ( { message = { a = msg, } });
      connected = testA canPublish = testA
   else
      connected = false
      if hub then
         hub:unsubscribe ( )
      end
      subscribeChannel ( )
   end
end

function t:timer ( event )
   publishNOOB ( "KEEP ALIVE" )
end

subscribeChannel ()
timer.performWithDelay ( 1000, t, -1 )

There needs to be a bunch of variables that need to be declared and what not but ... I basically send out a keep-alive post every so often to make sure it can post... probably not the best solution but it seems to work... at least when I manually bring down the server and bring it back up...



[TOPIC: post.html]
#8

Jack01

[GLOBAL: userInfoPane.html]
Jack01
  • Pro
  • PipPipPipPipPipPip
  • 85 posts
  • Jedi

Hi Overtorment / all !

 

What you think of this comment : http://coronalabs.com/blog/2013/03/20/corona-cloud-1-0-is-here/#comment-17706

 

I am still building my realtime game with noobhub and I really am very happy with it. But I must admit I really have no clue on how the virtual server will hold with say couple thousand players ping pong-ing.

 

Btw how you guys compensate for lag and how to test lag?

 

grtz Jack



[TOPIC: post.html]
#9

chrisevans1001

[GLOBAL: userInfoPane.html]
chrisevans1001
  • Pro
  • PipPip
  • 23 posts
  • Member

Compensating for lag: https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

 

Sockets on 3G - some issues with certain providers but on the whole should work fine.



[TOPIC: post.html]
#10

overtorment

[GLOBAL: userInfoPane.html]
overtorment
  • Starter
  • PipPipPipPipPipPip
  • 69 posts
  • Jedi

Ive used similar RESTfull cloud solution for multiplyayer, and I must ssay that laga were terrible. REST will never have a good latency, thats the reason why Ive built Noobhub. There were reportings that with proper tuning single nodejs server can hold up to 1 million concurrent connections. Anyway, if youre worried - set up several servers, and create a decision mechanism on which particcular server each user will hang. Obviously, US users should use server in US, that will greatly improve latency; same for european users.

[TOPIC: post.html]
#11

overtorment

[GLOBAL: userInfoPane.html]
overtorment
  • Starter
  • PipPipPipPipPipPip
  • 69 posts
  • Jedi

Compensating for lag: https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
 
Sockets on 3G - some issues with certain providers but on the whole should work fine.



I used same tutorial to learn multiplayer networking and latency compensation.


As for connections - once I implement auto-reconnect and resubscribe, hope there wont be any issues with connectivity at all. Unless the internet link is totally dead, of course.

[TOPIC: post.html]
#12

Jack01

[GLOBAL: userInfoPane.html]
Jack01
  • Pro
  • PipPipPipPipPipPip
  • 85 posts
  • Jedi

Thx for your replies. Any chance on an example for auto-reconnect / resubscribe? 



[TOPIC: post.html]
#13

overtorment

[GLOBAL: userInfoPane.html]
overtorment
  • Starter
  • PipPipPipPipPipPip
  • 69 posts
  • Jedi

I have just added auto-reconnect in case of network failure.

Grab it from Github.



[TOPIC: post.html]
#14

Jack01

[GLOBAL: userInfoPane.html]
Jack01
  • Pro
  • PipPipPipPipPipPip
  • 85 posts
  • Jedi

You rock  B)



[TOPIC: post.html]
#15

vitalitymobile1

[GLOBAL: userInfoPane.html]
vitalitymobile1
  • Starter
  • Pip
  • 7 posts
  • Newbie

Hi @jack01,

Can you share some lines of code how to combine a authentication system with this Noobhub server.

With authenticate user system, it will be rock!

My email is vitalitymobile at gmail dot com.

Thanks so much!



[TOPIC: post.html]
#16

Jack01

[GLOBAL: userInfoPane.html]
Jack01
  • Pro
  • PipPipPipPipPipPip
  • 85 posts
  • Jedi

Hi Vitality,

 

My code is pretty specific for my game but in general you can do the following.

 

Find a auth service which is reliable, for example https://github.com/braitsch/node-login

Set it up as a website and play with it, it will run on MongoDB.
 

If you dont want to use it as a support or stats website for your players than you can disable it (might also be saver), but you can conveniently use the account-manager.js for things like login, update and create an account. Make sure you install MongoDB global, so the the accounts db keeps running.

So in my noobhub js server I include a bit modified version like this. 

var AM = require('./functions/account-manager');

 

Then in noobhub js server you can do stuff like

                if (jsonobj.action == "login") {
                    console.log("MongoDB looks for this account: " + jsonobj["nickNameField"], jsonobj["passwordField"]);
                    AM.manualLogin(
                        jsonobj["nickNameField"],
                        jsonobj["passwordField"],
                        function (e, o) {
                        if (!o) {
                            //res.send(e, 400);
                            console.log("error calling AM.manualLogin in nodeserver.js :" + e);
                            if (e == 'user-not-found') {
                                var message = {
                                    "action":"Login_fails_on_user"
                                };
                            } else if (e == 'invalid-password') {
                                var message = {
                                    "action":"Login_fails_on_pass"
                                };
                            }
                        } else {
                            //res.send('ok', 200);
                            console.log("Login succes");
                            var message = {
                                "action":"Login_succes",
                                "avatar":o.avatar,
                                "email":o.email
                            };
                        }
                        message = JSON.stringify(message);
                        socket.write("__JSON__START__" + message + "__JSON__END__");
                    });
                }

 

 

So in your login.lua you can do something like this when submitting native.newTextFields

hub:publish({
        message = {
            action = "login",
            nickNameField = nickNameField.text,
            passwordField = password
        }
    });

 

And check if login succeeded etc in login.lua easily with

if(message.action == "Login_succes") then
  ....
  userSettings.nickName = nickNameField.text
  ....
  -- store in local settings
  loadsave.saveTable(userSettings, "userSettings.json")

 

I use an older version of node-login in which I implemented another security crypto, cuz in the older version Bcrypt was used which gave me lots of problems to get it running on the Ubuntu server (this is only needed if you want people to be able to register and login via a website too, but the new node-login seems to be good as it is). When creating an account and thus a pass in Corona, I crypto.hmac the pass on the phone in Corona with a salt so never uncrypted passwords are send. On the server the pass can be verified by simply comparing the values of the send and the stored encrypted passwords.

 

Logging out is nothing else than throwing away the local Corona settings like username etc. which you could store in a settings file https://github.com/Zillion01/Simple-Table-Load-Save-Functions-for-Corona-SDK (forked from Rob Miracle).

 

But of course you will need to dig in noobhub and node.js a bit, the node-login js took me a while to understand but works pretty awesome.

 

Good luck  :)

 

Btw Noobhub ROCKS. Lets help eachother a little here so we indies dont need to buy those way to expensive other services - *cough* of which some are not even yet realtime *cough*  :lol:



[TOPIC: post.html]
#17

vitalitymobile1

[GLOBAL: userInfoPane.html]
vitalitymobile1
  • Starter
  • Pip
  • 7 posts
  • Newbie

Thanks so much Jack01, I will read it more detail but for now I can say that you are awesome and Noobhub Rocks! really! :lol: 



[TOPIC: post.html]
#18

Richards App Store

[GLOBAL: userInfoPane.html]
Richards App Store
  • Starter
  • PipPip
  • 21 posts
  • Member

Hello all. You might remember me @overtorment, when you released noobhub I was one of the first few guys to start using it. I've got comments all over the original noobhub thread. Anyways, noobhub has worked great in my children's game "Math Race Online" since late August w/ the exception of the small bug where node would catch an error and end the script. Since you fixed that and released the new nodejs a few months back, the script has literally been running for 2 months straight without a single restart, which is fantastic! I'm using noobhub in a new project, and I am running into a small barrier. The app has to keep time in sync between the user and the host. so if a user joins a room, and the game is at 25 minutes 30 seconds and 873 milliseconds, the host has to send that time to the user and the user needs to know (almost) exactly how long ago the host send that number, so that say if the host sends to the user:

 

Time: 18 minutes, 3 seconds, 322 milliseconds,

 

then when the user receives that pong, I need the user to know how many milliseconds ago the request was sent so that the number of milliseconds of latency can be removed from the actual time sent by the host so that the host and the user are in sync.

 

My question is, is there anything built into noobhub that tells you what the latency of a ping/pong was? I thought about just having the host send a (1) ping, storing the system.getTimer() when the ping was sent, then (2) when the client receives this ping, pong the host back acknowledging ping received. then the host can substract the new system.getTimer() from the old one when the ping was sent, and divide that by 2 and send that to the client notifying them that is the latency in milliseconds. Obviously this wouldn't be fully accurate, but I was in a rush when I thought of it. If there isn't anything built in to tell latency, does anyone have any suggestions of ways this could be custom coded?

 

Note: the time has to be in milliseconds, not seconds.

 

Thanks!

Tyler



[TOPIC: post.html]
#19

nurzhantolegenov

[GLOBAL: userInfoPane.html]
nurzhantolegenov
  • Pro
  • PipPip
  • 27 posts
  • Member

Can we make noobhub save some data? For example to create a leaderboard. :rolleyes:



[TOPIC: post.html]
#20

overtorment

[GLOBAL: userInfoPane.html]
overtorment
  • Starter
  • PipPipPipPipPipPip
  • 69 posts
  • Jedi

Hello all. You might remember me @overtorment, when you released noobhub I was one of the first few guys to start using it. I've got comments all over the original noobhub thread. Anyways, noobhub has worked great in my children's game "Math Race Online" since late August w/ the exception of the small bug where node would catch an error and end the script. Since you fixed that and released the new nodejs a few months back, the script has literally been running for 2 months straight without a single restart, which is fantastic! I'm using noobhub in a new project, and I am running into a small barrier. The app has to keep time in sync between the user and the host. so if a user joins a room, and the game is at 25 minutes 30 seconds and 873 milliseconds, the host has to send that time to the user and the user needs to know (almost) exactly how long ago the host send that number, so that say if the host sends to the user:

 

Time: 18 minutes, 3 seconds, 322 milliseconds,

 

then when the user receives that pong, I need the user to know how many milliseconds ago the request was sent so that the number of milliseconds of latency can be removed from the actual time sent by the host so that the host and the user are in sync.

 

My question is, is there anything built into noobhub that tells you what the latency of a ping/pong was? I thought about just having the host send a (1) ping, storing the system.getTimer() when the ping was sent, then (2) when the client receives this ping, pong the host back acknowledging ping received. then the host can substract the new system.getTimer() from the old one when the ping was sent, and divide that by 2 and send that to the client notifying them that is the latency in milliseconds. Obviously this wouldn't be fully accurate, but I was in a rush when I thought of it. If there isn't anything built in to tell latency, does anyone have any suggestions of ways this could be custom coded?

 

Note: the time has to be in milliseconds, not seconds.

 

Thanks!

Tyler

 

 

Hello Tyler!

Glad youre making use of Noobhub.

Regarding the lag determination - you're on the right track, but here, take a look at algorithm I came up with to determine lags for my own game.

 

lag_compensation.png

 

 

Basically,  A constantly pings B, and saves ping latency to determine basic network latency.

And tracking timestamps of message  sending/receiving, it is possible to tell  how much more message was delayed on top of the basic network latency. Take a look at the scheme I made.



[TOPIC: post.html]
#21

overtorment

[GLOBAL: userInfoPane.html]
overtorment
  • Starter
  • PipPipPipPipPipPip
  • 69 posts
  • Jedi

Can we make noobhub save some data? For example to create a leaderboard.

 

I was thinking about it, and created a solution which doesn't involve server code modification.

Basically, I made a php script hang on some noobhub channel, so it can do some backend work, like saving and retrieving data.

Example script is in "client/php/" folder.

Cheers!



[TOPIC: post.html]
#22

Richards App Store

[GLOBAL: userInfoPane.html]
Richards App Store
  • Starter
  • PipPip
  • 21 posts
  • Member

That works for me! The app just needs to sync times once between the host and the users, so I won't have to worry about rechecking constantly because once I know the ping I can subtract it from the round time and start the timer, so good to go there. Thanks a lot!

 

Tyler



[TOPIC: post.html]
#23

drazen007bond

[GLOBAL: userInfoPane.html]
drazen007bond
  • Starter
  • Pip
  • 2 posts
  • Newbie

Actually, there's a php client in the repo. Its provides console  access to the channel, so you can type commands to channel and receive what's the other end sending. I use it for remote debugging on real device.

It can be handy to implement simple commands in Lua, so you can type lile. "Img1.x = 100" in console and this will instantly apply in your app (handy to fix issues on real device instead of simulator)

Could you also post the link to your app..?

 

 

 

 

Experienced no issues on this  yet... Anyway gona implement silent reconnect mechanism in Lua client, that should fix most connection issues.

Excuse my ignorance, but can you explain how are you using php client for commands like img1.x=111.

 

I would also like to know (if satheesh from discussion on http://developer.coronalabs.com/code/noobhub is here) 

how his application is working without Internet connection. As I understand that would mean that node is running on mobile phone !?



[TOPIC: post.html]
#24

Richards App Store

[GLOBAL: userInfoPane.html]
Richards App Store
  • Starter
  • PipPip
  • 21 posts
  • Member

Hey @overtorment or anyone else who knows the answer to this, all of a sudden im randomly getting this error "Exception: Error: ETIMEDOUT, Connection timed out" after using the same channel consistently. Any idea what is causing this error? It's not letting the channel continue to be used, and is displaying the error "Exception: Error: Socket is not writable" whenever I try to ping/pong it after it gives me the initial error. If there's any way to fix this I'd love to know, just worried that the cause is from excessive use of a channel. But if that's the case then it's going to be a problem for my app.

 

Thanks,

Tyler



[TOPIC: post.html]
#25

overtorment

[GLOBAL: userInfoPane.html]
overtorment
  • Starter
  • PipPipPipPipPipPip
  • 69 posts
  • Jedi

Tyler, have you updated client's lib (noobhub.lua file) ?

In latest version I implemented auto-reconnect if connection gets broken (timeout or anything else), I believe this should fix your issue.

 

 

@drazen007bond

In my game I implemented simple command recognition engine, so game can receive some command to change coordinates of something, and do it. For that, game subscribes to a dedicated channel, like, "debug-channel".

I set-up my php script to connect to the same channel "debug-channel", and type commands. 




[topic_controls]
Page 1 of 8 1 2 3 »
 
[/topic_controls]



Also tagged with one or more of these keywords: multiplayer, opensource, net, network