Coder Social home page Coder Social logo

ali1rh / sub.socket.io Goto Github PK

View Code? Open in Web Editor NEW

This project forked from braitsch/sub.socket.io

1.0 0.0 0.0 183 KB

Example of how to run Socket.IO on multiple subdomains in the form of a simple chat server.

Home Page: http://chat.braitsch.io/

JavaScript 45.57% CSS 18.07% Pug 18.18% Stylus 18.17%

sub.socket.io's Introduction

An example of how to share a single Socket.IO instance over multiple subdomains in the form of running three independent chat servers.

Installation

git clone git://github.com/braitsch/sub.socket.io.git socket-io-example
cd socket-io-example

This project contains three separate applications, a root application (mydomain.com) that instantiates the Socket.IO instance and two subdomain applications that listen for incoming connections in their own namespace.

mydomain.com
sub1.mydomain.com
sub2.mydomain.com

Note these applications can obviously be anything you like but for the purposes of this example they are just three instances of the exact same chat application running in three separate namespaces.

So to get these up and running, cd into each application and install its dependencies :

cd mydomain.com
npm install
cd ../sub1.mydomain.com
npm install
cd ../sub2.mydomain.com
npm install
cd ../mydomain.com

Now open your /etc/hosts file in your editor of choice and add the following two subdomains so we can view them in a browser.

Somewhere after 127.0.0.1 localhost and before 255.255.255.255 broadcasthost add the following two lines :

127.0.0.1 sub1.localhost
127.0.0.1 sub2.localhost

Save and exit the file. Ensure you are inside of the mydomain.com directory and start the root application.

node app

Now point your browser at :

http://localhost:8080
http://sub1.localhost:8080
http://sub1.localhost:8080

And you should have three isolated instances of the chat server running, all sharing the same Socket.IO instance.

sub.socket.io's People

Contributors

braitsch avatar

Stargazers

 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.