remove websocket shit
This commit is contained in:
parent
804681c47a
commit
a2889169c3
@ -18,9 +18,8 @@
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"fs-extra": "^7.0.0",
|
||||
"socket.io": "^2.1.1",
|
||||
"sqlite": "^3.0.0",
|
||||
"sqlite3": "^4.0.3",
|
||||
"ws": "^6.1.3"
|
||||
"sqlite": "^3.0.2",
|
||||
"sqlite3": "^4.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.3",
|
||||
|
@ -112,19 +112,6 @@
|
||||
<option value="desc">Descending order</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="separator">Remote Control</div>
|
||||
<div class="option checkbox">
|
||||
<label for="st-remote">Allow remote control</label>
|
||||
<input type="checkbox" id="st-remote" name="remote">
|
||||
</div>
|
||||
<div class="option">
|
||||
<label for="st-device">Device name</label>
|
||||
<input type="text" id="st-device" name="device">
|
||||
</div>
|
||||
<div class="option action">
|
||||
<button id="dc">Take Remote Control</button>
|
||||
<button id="dc-stop">Release Remote</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -45,9 +45,7 @@
|
||||
trackids: true,
|
||||
streamable: true,
|
||||
sortby: 'id',
|
||||
sortdir: 'asc',
|
||||
device: '',
|
||||
remote: false
|
||||
sortdir: 'asc'
|
||||
}
|
||||
|
||||
window.mobilecheck = function() {
|
||||
|
@ -1,75 +0,0 @@
|
||||
import WebSocket from 'ws'
|
||||
|
||||
const wss = new WebSocket.Server({ noServer: true })
|
||||
|
||||
function getClientByDevice (dev) {
|
||||
for (let i in wss.clients) {
|
||||
let client = wss.clients[i]
|
||||
if (client.device === dev) return client
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
wss.on('connection', function (ws) {
|
||||
ws.on('device', function (devid) {
|
||||
ws.device = devid
|
||||
})
|
||||
|
||||
ws.on('connect', function (devid) {
|
||||
let target = getClientByDevice(devid)
|
||||
if (!target) return ws.emit('errno', { code: 100, error: 'Target device is not available.' })
|
||||
target.emit('request', ws.device)
|
||||
})
|
||||
|
||||
ws.on('detach', function () {
|
||||
if (!ws.controlled) return
|
||||
ws.controlled = null
|
||||
let target = getClientByDevice(devid)
|
||||
if (!target) return
|
||||
target.controller = null
|
||||
target.emit('detach')
|
||||
})
|
||||
|
||||
ws.on('accept', function (devid) {
|
||||
ws.controller = devid
|
||||
let target = getClientByDevice(devid)
|
||||
if (!target) return ws.emit('errno', { code: 100, error: 'Target device is not available.' })
|
||||
target.controlled = devid
|
||||
target.emit('accepted', devid)
|
||||
})
|
||||
|
||||
ws.on('play', function (id) {
|
||||
if (!ws.controlled) return
|
||||
let target = getClientByDevice(ws.controlled)
|
||||
if (!target) return ws.emit('errno', { code: 100, error: 'Target device is not available.' })
|
||||
target.emit('play', id)
|
||||
})
|
||||
|
||||
ws.on('seekto', function (num) {
|
||||
if (!ws.controlled) return
|
||||
let target = getClientByDevice(ws.controlled)
|
||||
if (!target) return ws.emit('errno', { code: 100, error: 'Target device is not available.' })
|
||||
target.emit('seekto', num)
|
||||
})
|
||||
|
||||
ws.on('volumeto', function (num) {
|
||||
if (!ws.controlled) return
|
||||
let target = getClientByDevice(ws.controlled)
|
||||
if (!target) return ws.emit('errno', { code: 100, error: 'Target device is not available.' })
|
||||
target.emit('volumeto', num)
|
||||
})
|
||||
})
|
||||
|
||||
module.exports = function (server) {
|
||||
server.on('upgrade', function (request, socket, head) {
|
||||
const pathname = url.parse(request.url).pathname
|
||||
|
||||
if (pathname === '/remote') {
|
||||
wss.handleUpgrade(request, socket, head, function (ws) {
|
||||
wss.emit('connection', ws, request)
|
||||
})
|
||||
} else {
|
||||
socket.destroy()
|
||||
}
|
||||
})
|
||||
}
|
@ -7,7 +7,6 @@ import https from 'https'
|
||||
import ffmpeg from 'fluent-ffmpeg'
|
||||
|
||||
import lfmda from './lastfm'
|
||||
import remote from './remote-control'
|
||||
|
||||
require('express-async-errors')
|
||||
|
||||
@ -224,9 +223,6 @@ app.use('/', express.static(path.join(process.cwd(), 'public')))
|
||||
|
||||
const host = process.env.NODE_ENV === 'development' ? '0.0.0.0' : '127.0.0.1'
|
||||
|
||||
// Initialize remote control
|
||||
remote(server)
|
||||
|
||||
server.listen(port, host, function () {
|
||||
console.log(`app running on port ${port}`)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user