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!
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!
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
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.
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:
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.
[quote name=“chrisevans1001” post=“171321” timestamp=“1364120051”]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.[/quote] 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.
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:
Thx for your replies. Any chance on an example for auto-reconnect / resubscribe?
I have just added auto-reconnect in case of network failure.
Grab it from Github.
You rock B)
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!
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:
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:
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
Can we make noobhub save some data? For example to create a leaderboard. :rolleyes:
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.
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.
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!
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
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 !?
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