Giter Site home page Giter Site logo

overtorment / noobhub Goto Github PK

View Code? Open in Web Editor NEW
313.0 39.0 53.0 132 KB

🌐🔥 Network multiplayer and messaging for CoronaSDK, Moai, Gideros, LÖVE & Defold

JavaScript 20.23% Lua 73.96% PHP 2.65% Batchfile 1.46% Shell 0.51% HTML 1.20%
corona-sdk gideros lua moai pubsub nodejs networking love2d wtfpl

noobhub's Introduction

NoobHub

JavaScript Style Guide

OpenSource multiplayer and network messaging for CoronaSDK, Moai, Gideros, LÖVE & Defold

Battle-tested and production ready. Handling thousands of CCU (concurrent users), serving hundreds of thousands multiplayer games daily, routing hundreds of messages per second, with months of uptime.

  • 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.
  • Zero dependency. Works out of the box, no NPM ecosystem required. (for websocket bridge relies on ws module, read below)
  • Socket connections, works great through any NAT (local area network), messages delivery is reliable and fast.
  • Low CPU and memory footprint

Repo includes server code (so you can use your own server) and CoronaSDK/Moai/Gideros/LÖVE client. More clients to come. You can test on my server, credentials are hardcoded in demo project!

Lua code may serve as an example of how LuaSocket library works.

How to use it

START SERVER

        $ nodejs node.js

To make use of the websocket bridge, uncomment wsPort in the config.
If so, make sure to do npm install as well.
These are useful to serve browser clients. Irrelevant otherwise.

INITIALIZE

        hub = noobhub.new({ server = "127.0.0.1"; port = 1337; });
const hub = noobhub.new({ server: '127.0.0.1', port: 2337 });

SUBSCRIBE TO A CHANNEL AND RECEIVE CALLBACKS WHEN NEW JSON MESSAGES ARRIVE

        hub:subscribe({
          channel = "hello-world";
        	callback = function(message)

        		if(message.action == "ping")   then
        			print("Pong!")
        		end;

        	end;
        });
hub.subscribe({
  channel: 'hello-world',
  callback: (data) => {
    console.log('callback', data);
  }
});

SAY SOMETHING TO EVERYBODY ON THE CHANNEL

        hub:publish({
            message = {
                action  =  "ping",
                timestamp = system.getTimer()
            }
        });
hub.publish({
  action: 'ping',
  timestamp: Date.now()
});

Clients

  • CoronaSDK
  • Gideros
  • Moai
  • LÖVE
  • Node.js
  • PHP (debug console only)
  • JS / Browser

Tests

Simple acceptance test uses Nodejs client to test the server itself:

    $ ./run-tests.sh
    starting Noobhub server...
    NoobHub on :::1337
    running tests...
    tests ok

Getting ready for production use

If you expect more than 1000 concurrent connections, you should increase limits on your server (max open file descriptors, max TCP/IP connections) and optionally fine-tune your server's TCP/IP stack. To make sure server process stays alive you might want to use tools such as forever.js or supervisord.

Authors

  • Igor Korsakov
  • Sergii Tsegelnyk

Licence

WTFPL

Official discussion thread

noobhub's People

Contributors

bitdeli-chef avatar dependabot[bot] avatar dr3am3r avatar dynlab-build avatar josepedrodias avatar namelis avatar overtorment avatar tst2005 avatar tylerr94 avatar zillion01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

noobhub's Issues

Error: targetStart out of bounds

[Error: oob]
[Error: targetStart out of bounds]

This happens when I publish data continuously for a long time.
After this error occurs, the socket which published all the data, cannot publish any more data.. It receives data though..

This answer at http://stackoverflow.com/a/10933958/1137788 says this can happen when you try to manipulate the length of a fixed size allocation in memory by the += method

Problem running NoobHub on AWS

I'm trying to run the server on AWS. I can connect (I see the "New Client" log) but socket.on() never fires. I have verified that the client sends the subscribe message (In my case 40 bytes written and no error), but it never reaches the server. Do you happen to know of anything in particular that needs to be done to get it to work on AWS?

TODO: rewrite connection

Like in this example I found on the web

s=socket.tcp() s:settimeout(0) return s:connect("192.168.41.2", 9000)

Also, if possible, return error, message in return statement (for the consumer to process it correctly)

License

What license is the library licensed under?

Connection Fails on Android Device

Using noobhub within the Corona SDK Simulator I have no problems connecting to my remote server. I Build for Android using Corona, download the apk and install, the connection immediately fails. I wrote a little handler to pop up a widget on connection failed - happens immediately upon initiating connection.

tcpdump on my remote server, on the listening port (kept tcp.1337 in case my DNAT was causing issues, even though TCP shouldnt care) shows no connections even trying to come in. The tcpdump does show communication from my Corona Simulator (just for thorough testing).

I am guessing this may be a security "feature" on the phone? Same results on both devices tested on:
Note 2 - Android Ver 4.4.2
LG G3 - Android Ver 4.4.4 with cyanogenmod

npm package

Hi, i was wondering if there are any plans to publish an official npm package for NoobHub. I think it would be useful.

C#/Unity client

Is C#/.Net/Mono (Unity) client planned? It would be very useful, as I've become addicted to your library while using Corona, but now we are moving to new engine and searching for an replacement (there is none, or they are outdated).

Android disconnecting and freezing

Hi!

I'm having a problem with android, where the socket gets disconnected after a while and the app gets stuck until I can connect again.

Has anyone gone through this?

Unity3D

Is there a client in C# for Unity3D?

Thank you.

Error: read ETIMEDOUT

events.js:66
throw arguments[1]; // Unhandled 'error' event
^
Error: read ETIMEDOUT
at errnoException (net.js:781:11)
at TCP.onread (net.js:423:21)
at process.startup.processMakeCallback.process._makeCallback
(node.js:248:20)

Write server-side code for client-server game?

Hi Overtorment,

I want to write an online game (with server/client model), but I don't know how to create server-side code with NoobHub? I know NoobHub is pub/sub system, your server code is only a message delivery system betwen clients. Should I modify your server code or only create a "super client" subscribe all client's message as server logic process ?

Buffer() deprecated in Node 10

Buffer() has been deprecated in Node v10. buffer.alloc() seems very suitable to replace buffer() in noobhub. I made the change myself and it seems to be running with stability on my end, just thought I'd raise the issue here so that people going forward are aware of this deprecation error and how to address it.

Can't get external connections to work

There's no way I can connect to the server from an external IP. It works if I use 127.0.0.1 or use my PC's private IP, but it doesn't work if I try with the public IP.

I've already tried adding "0.0.0.0", "localhost" and "127.0.0.1" to server.listen(cfg.port), forwarding the 1337 port, editing iptables. Nothing works.

Noobhub server alternative implementation

Hello,

I planned to make lua code to support noobhub at server side, mainly for a love2d peer-to-peer app, maybe also for nginx (openresty).
I wonder if someone still use noobhub and are interested ?

Regards,

a little suggestion

This is not a bug, but a little suggestion.
NoobHub is a great project, it would be much better if a little modification made to the search for the socket to remove in the 'close' function of the server,maybe a hash table is good choice for storing the sockets

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.