Update hello world
This commit is contained in:
parent
b68f86adeb
commit
dcccf3c2f2
@ -154,6 +154,18 @@ function register ({ registerHook, registerSettingsScript, registerClientRoute,
|
||||
rootEl.innerHTML = 'hello'
|
||||
}
|
||||
})
|
||||
|
||||
// WebSocket
|
||||
|
||||
const baseScheme = window.location.protocol === 'https:'
|
||||
? 'wss:'
|
||||
: 'ws:'
|
||||
|
||||
const socket = new WebSocket(baseScheme + '//' + window.location.host + peertubeHelpers.getBaseWebSocketRoute() + '/toto');
|
||||
|
||||
socket.addEventListener('message', (event) => {
|
||||
console.log(event.data)
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
|
@ -66,6 +66,8 @@ function register ({ registerHook, peertubeHelpers }) {
|
||||
registerHook({
|
||||
target: 'filter:internal.player.videojs.options.result',
|
||||
handler: (options) => {
|
||||
console.log(options.plugins.p2pMediaLoader)
|
||||
|
||||
options.poster = ''
|
||||
return options
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
const WebSocketServer = require('ws').WebSocketServer
|
||||
|
||||
async function register ({
|
||||
registerHook,
|
||||
getRouter,
|
||||
registerWebSocketRoute,
|
||||
registerSetting,
|
||||
settingsManager,
|
||||
storageManager,
|
||||
@ -163,6 +166,27 @@ async function register ({
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// WebSocket
|
||||
const wss = new WebSocketServer({ noServer: true })
|
||||
|
||||
wss.on('connection', function connection(ws) {
|
||||
peertubeHelpers.logger.info('Websocket connected!')
|
||||
|
||||
setInterval(() => {
|
||||
ws.send('Websocket message sent by server');
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
registerWebSocketRoute({
|
||||
route: '/toto',
|
||||
|
||||
handler: (request, socket, head) => {
|
||||
wss.handleUpgrade(request, socket, head, ws => {
|
||||
wss.emit('connection', ws, request)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function unregister () {
|
||||
|
43
peertube-plugin-hello-world/package-lock.json
generated
Normal file
43
peertube-plugin-hello-world/package-lock.json
generated
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "peertube-plugin-hello-world",
|
||||
"version": "0.0.20",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "peertube-plugin-hello-world",
|
||||
"version": "0.0.20",
|
||||
"dependencies": {
|
||||
"ws": "^8.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.9.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz",
|
||||
"integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": "^5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"ws": {
|
||||
"version": "8.9.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz",
|
||||
"integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==",
|
||||
"requires": {}
|
||||
}
|
||||
}
|
||||
}
|
@ -78,5 +78,8 @@
|
||||
],
|
||||
"translations": {
|
||||
"fr": "./languages/fr.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"ws": "^8.9.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user