GithubHelp home page GithubHelp logo

nmcclay / node-poolboy Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 184 KB

A Node.js TCP connection pool server I wrote for a unity game I helped with for the 2012 Global Game Jam.

JavaScript 100.00%

node-poolboy's Introduction

TCP Connection Pool for Node.js

To install:

npm install poolboy

To setup:

// import poolboy
var poolboy = require('poolboy');
// create connection pool with request port
var poolServer = poolboy.setupConnectionPool(5000);

TCP requests to port 5000 will now setup a new socket and return the socket port for a new tcp connection

Listening for new connections

// event for when a client connects to the request port and creates a new port
poolServer.on('newport',function(port) {
	console.log("new socket created on port " + port.address().port)
})

Manually adding new connections:

// assigns new port
var newServer = poolboy.add()
// assigns a new specific port number
var newSpecificServer = poolboy.add(1234)

Serving cross domain policy documents:

currently supports unity/flash cross domain policy format

poolboy.crossPolicyEnabled = true;
poolboy.crossPolicyPort = 8080; // defaults to 3001

Parse JSON responses:

poolboy.jsonEmitEnabled = true;

poolServer.on('newport',function(port) {
	port.on('json',function(json) {
		console.log("got a json object!",json);
	})
})

node-poolboy's People

Contributors

nmcclay avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.