Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
feat: basic functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
severo committed Jan 15, 2020
1 parent ebfd934 commit 266aaa9
Show file tree
Hide file tree
Showing 5 changed files with 5,288 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)

Central server for users collaboration on web applications.
Socket server for users collaboration on web applications.

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

## Versions

Expand Down
6 changes: 6 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Node.js Socket.io server",
"description": "Allows users to collaborate on the same application state",
"repository": "https://github.com/LyonDataViz/socket-server",
"keywords": ["node", "websocket", "socket.io"]
}
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const express = require('express')
const app = express()
const http = require('http').Server(app)
const io = require('socket.io')(http)
const port = process.env.PORT || 3000

// TODO: add a public page that redirects to the GitHub repository
// app.use(express.static(__dirname + '/public'))

function onConnection(socket) {
socket.on('chat', data => {
// console.log(`Message received: ${data}`)
socket.broadcast.emit('chat', data)
})
}

io.on('connection', onConnection)

http.listen(port, () => console.log('listening on port ' + port))
Loading

0 comments on commit 266aaa9

Please sign in to comment.