20 lines
549 B
JavaScript
20 lines
549 B
JavaScript
import s from "apigo.cc/gojs/service"
|
|
import co from "apigo.cc/gojs/console"
|
|
|
|
function main() {
|
|
s.register({
|
|
method: 'WS', path: '/ws',
|
|
onMessage: ({ client, type, data }) => {
|
|
client.writeMessage(type, data)
|
|
},
|
|
onClose: ({ client }) => {
|
|
co.info('ws closed', client.id)
|
|
s.dataRemove('wsTest', client.id)
|
|
}
|
|
}, ({ client }) => {
|
|
co.info('ws connected', client.id)
|
|
s.dataSet('wsTest', client.id, client)
|
|
client.write('Hello, World!')
|
|
})
|
|
}
|