Created
July 26, 2017 17:58
-
-
Save brunocarvalhodearaujo/c612b91a07681deba33dbc751c8b4871 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket from 'socket.io' | |
/** | |
* @type {socket} | |
*/ | |
const io = socket() | |
/** | |
* @param {number} code dsadsad as | |
* @param {socket} socket - dsads dsad as | |
*/ | |
function connection (code, socket) { | |
} | |
/** | |
* @typedef {{ [id: string]: socket }} client | |
* @type {client} client -dsadslapdlsa | |
*/ | |
const clients = {} | |
io.sockets.on('connection', client => { | |
client.on('join', name => {}) | |
clients[ client.id ] = client | |
client.emit('update', 'you have connected to the server') | |
client.broadcast.emit('update', `${client.id} has joined the server`) | |
client.on('send', message => { | |
client.broadcast.emit('chat', clients[client.id], message) | |
}) | |
}) | |
export default io |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment