GithubHelp home page GithubHelp logo

akmalsyrf / socket.io-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dumbwaysdotid/socket.io-template

0.0 0.0 0.0 513 KB

Meeting 9

HTML 1.41% JavaScript 93.26% CSS 5.26% Shell 0.08%

socket.io-template's Introduction

Prepare

Before integrate our application with Socket.io, we make some preparations, including:

  • Install package socket.io on client and server

On server:

npm install socket.io

On client:

npm install socket.io-client
  • Server initialization
// import package
const http = require('http')
const {Server} = require('socket.io')

// add after app initialization
const server = http.createServer(app)
const io = new Server(server, {
 cors: {
   origin: 'http://localhost:3000' // define client origin if both client and server have different origin
 }
})

// change app to server
server.listen(port, () => console.log(`Listening on port ${port}!`))

socket.io-template's People

Contributors

yosepalexsander avatar akmalsyrf 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.