支持 load 加载的服务热更新(需配置hotLoad) 增强唯一id获取(使用新算法,依赖Redis) session支持基于细粒度权限匹配(传入支持的功能列表匹配)
23 lines
688 B
JavaScript
23 lines
688 B
JavaScript
import s from "apigo.cc/gojs/service"
|
|
import co from "apigo.cc/gojs/console"
|
|
import task from "apigo.cc/gojs/task"
|
|
|
|
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)
|
|
task.remove('wsTest_' + client.id)
|
|
}
|
|
}, ({ client }) => {
|
|
co.info('ws connected', client.id)
|
|
// s.dataSet('wsTest', client.id, client)
|
|
task.set('wsTest_' + client.id, client)
|
|
client.write('Hello, World!')
|
|
})
|
|
}
|