Created
May 22, 2017 14:44
-
-
Save mpj/109110438543e68ae63a721c2ac5a782 to your computer and use it in GitHub Desktop.
minimal json forwarder with socket io
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
const socket = window.io('http://localhost:3001') | |
socket.on('events', message => console.log('events', message) ) |
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
<script src="http://localhost:3001/socket.io/socket.io.js"></script> |
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
var app = require('express')() | |
var http = require('http').Server(app) | |
var io = require('socket.io')(http) | |
app.use(require('body-parser').json()) | |
app.post('/emit', (req, res) => { | |
io.emit('events', req.body) | |
res.send('OK') | |
}) | |
http.listen(3001, () => console.log('listening ...')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment