require('express')() var http = require('http').Server(app) var io = require('socket.io')(http, { path: '/pathto/socket.io' }) var axios = require('axios') const SERVER_PORT = process.env.SERVER_PORT io.on('connection', socket => { socket.on('event', msg => { console.log('event: ' + msg) io.emit('event', msg) }) }) http.listen(SERVER_PORT, () => { console.log('Socket.IO on *:' + SERVER_PORT) }) import io from 'socket.io-client' var socket = io({ path: '/pathto/socket.io', query: { token: token } }) socket.on('event', message => { let event = JSON.parse(message) switch (event.name) { case 'lock': // ロック時の処理 break case 'unlock': // ロック開放時の処理 break } }) function sendEvent (payload) { socket.emit('event', JSON.stringify(payload)) } サーバ側(14行) ※socket.io部分以外は省略しました