Compare commits

...

10 Commits

3 changed files with 177 additions and 55 deletions

132
.gitignore vendored
View File

@@ -1,63 +1,113 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# how to include another gitignore?
# https://stackoverflow.com/questions/7005142/can-i-include-other-gitignore-file-in-a-gitignore-file-like-include-in-c-li
# https://github.com/github/gitignore
# https://github.com/SlideWave/gitignore-include?tab=readme-ov-file#examples
# https://gitignore.io
node_modules/
/test/unit/coverage/
/test/e2e/reports/
### .gitignore.global.txt ###
# Self defined pattern to ignore
?*.gitignore
?*.gitignore/
?*.gitignore.*
?*.gitignore.*/
*.gitomit
*.gitomit.*
*.gitomit/
*.gitomit.*/
*.nogit
*.nogit.*
*.nogit/
*.nogit.*/
# 保留
!.gitignore
!.gitignore.*
!.gitkeep
# 通用
.svn/
.deploy_git/
.idea/
.sass-cache/
.deploy_git/
.wrangler
/test/unit/coverage/
/test/e2e/reports/
node_modules/
*.aab
*.apk
*.ipa
*.min.js
*.min.css
*.min.html
*.iml
*.njsproj
*.ntvs*
*.sw*
*.sln
*.suo
.gitattributes
_desktop.ini
.DS_Store
.thumbnails
Thumbs.db
thumbs.db
.umi
.umi-production
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock
selenium-debug.log
package-lock.json
*.iml
*.njsproj
*.ntvs*
*.sln
*.suo
._*
.$*
~$*
Thumbs.db
thumbs.db
_desktop.ini
.bashrc_custom
# vue-cli 项目
/dist/
# 来自 vue-cli 创建项目的 .gitignore
.project
# hexo
db.json
/public/
# 客户端 uniapp 项目
/unpackage/dist
/unpackage/release
/unpackage/cache
# Hardhat
/artifacts/
/cache/
# seafile 临时文件
._*
.$*
# office 暂存文件
~$*
# 用户shell配置脚本
.bashrc_custom
# 苹果系统临时文件
.DS_Store
# 安卓缓存文件夹
.thumbnails
# local env files
.env.local
.env.*.local
# hexo
/db.json
# wo
# 服务端
/_archive/*
/_datastore/*
/_logstore/*
/_filestore/*
/_logstore/*
/_webroot/*
/dist/
*.apk
*.min.js
*.min.css
*.min.html
/pages4loader.json5
envar-web-custom.js
envar-deploy-secret.js
/_ssl/*
# uniapp 客户端
/unpackage/*
!/unpackage/res/
package-lock.json
pages4loader.json5
# hexo 项目
public/
### .gitignore.local.txt ###
# 服务端(server or uniapp-uniCloud)项目
envar-base-custom.js
envar-base-dynamic.js
envar-base-secret.js
!.gitkeep

View File

@@ -9,19 +9,19 @@ const DAD = (module.exports = class RpcSocket extends ws {
DAD.upgrade(ws)
}
static upgrade(ws) {
static upgrade (ws) {
ws.__proto__ = DAD.prototype
ws.sid = randomBytes(16).toString('hex')
ws.onmessage = async ({ data }) => {
// console.log('[onmessage] 被调用在 data =', data)
// console.log({ _at: new Date().toJSON(), about:'[onmessage] 被调用在 data =', data}, '\n,')
try {
let { rpcType, rpcHow, rpcWhat, randomEvent, rpcResult } = JSON.parse(data)
// console.log('message data parsed to ', {rpcType, rpcHow, rpcWhat, randomEvent, rpcResult})
// console.log({ _at: new Date().toJSON(), about:'message data parsed', rpcType, rpcHow, rpcWhat, randomEvent, rpcResult}, '\n,')
switch (rpcType) {
case 'SEND_REQUEST':
// 接收到异步的远程调用
// console.log(`被调方 收到 SEND_REQUEST: rpcHow=${rpcHow}, rpcWhat=${JSON.stringify(rpcWhat)}`)
// console.log({ _at: new Date().toJSON(), about:'被调方 收到 SEND_REQUEST', rpcHow, rpcWhat}, '\n,')
if (ws.hasOwnProperty(rpcHow)) rpcResult = await ws[rpcHow](rpcWhat)
else rpcResult = { _state: 'ERROR', _stateMsg: `unknown rpcHow=${rpcHow}` }
if (randomEvent) {
@@ -30,20 +30,20 @@ const DAD = (module.exports = class RpcSocket extends ws {
break
case 'SEND_RESULT':
// 接收到远程返回的结果
// console.log('主调方 收到 SEND_RESULT: rpcResult=', rpcResult)
// console.log({ _at: new Date().toJSON(),about:'主调方 收到 SEND_RESULT', rpcResult}, '\n,')
ws.emit(randomEvent, rpcResult)
break
case 'SEND_NOTIFY':
default:
// 接收到同步的远程调用 或者 标准ws的send(...)
// console.log(`被调方 收到 SEND_NOFITY: rpcHow=${rpcHow}, rpcWhat=${JSON.stringify(rpcWhat)}`)
// console.log({ _at: new Date().toJSON(),about:'被调方 收到 SEND_NOFITY', rpcHow, rpcWhat})
if (ws.hasOwnProperty(rpcHow)) ws[rpcHow](rpcWhat)
else if (ws.eventNames().indexOf(rpcHow) >= 0) ws.emit(rpcHow, rpcWhat)
else console.error('[onmessage] unknown rpc: ', rpcHow, rpcWhat)
else console.error({ _at: new Date().toJSON(), about: '[onmessage] unknown rpc', rpcHow, rpcWhat }, '\n,')
break
}
} catch (exception) {
console.error('[onmessage] invalid rpc data: ', data, exception)
console.error({ _at: new Date().toJSON(), about: '[onmessage] invalid rpc data', data, exception }, '\n,')
return
}
}
@@ -51,7 +51,7 @@ const DAD = (module.exports = class RpcSocket extends ws {
return ws
}
static connectAsync(url) {
static connectAsync (url) {
return new Promise(function (resolve, reject) {
let socket = new DAD(url)
socket.onopen = () => resolve(socket)
@@ -59,7 +59,7 @@ const DAD = (module.exports = class RpcSocket extends ws {
})
}
reconnectAsync(url) {
reconnectAsync (url) {
if (this.readyState === ws.CONNECTING || this.readyState === ws.OPEN) {
return Promise.resolve(this)
}
@@ -70,19 +70,19 @@ const DAD = (module.exports = class RpcSocket extends ws {
})
}
sendNotify({ rpcHow, rpcWhat, options, callback } = {}) {
sendNotify ({ rpcHow, rpcWhat, options, callback } = {}) {
// 发起同步的远程调用
this.send(JSON.stringify({ rpcType: 'SEND_NOTIFY', rpcHow, rpcWhat }), options, callback)
}
sendRequest({ rpcHow, rpcWhat, rpcCallback, timeout = 5000 } = {}) {
sendRequest ({ rpcHow, rpcWhat, rpcCallback, timeout = 5000 } = {}) {
// 发起异步的远程调用
let randomEvent = randomBytes(16).toString('hex')
// console.log('randomEvent is randomized: ', randomEvent)
// console.log({ _at: new Date().toJSON(),about:'randomEvent is randomized', randomEvent})
if (typeof rpcCallback === 'function') {
// 有回调
this.send(JSON.stringify({ rpcType: 'SEND_REQUEST', rpcHow, rpcWhat, randomEvent }), () => {
// console.log('in callback, randomEvent=', randomEvent)
// console.log({ _at: new Date().toJSON(),about:'in callback', randomEvent})
this.once(randomEvent, rpcCallback)
setTimeout(() => {
if (this.eventNames().indexOf(randomEvent) >= 0) {

72
seafile-ignore.txt Normal file
View File

@@ -0,0 +1,72 @@
# https://help.seafile.com/syncing_client/excluding_files/
# 注释。通配符:* 匹配0到若干个字符包括代表目录的/。? 匹配1个字符包括/。
# seafile-ignore.txt 只能控制在客户端需要忽略哪些文件。你依然可以在 seahub 的 web 界面创建这些被客户端忽略的文件。
# 在这种情况下,
# 这些文件会被同步到客户端,但是用户在客户端对这些文件的后续修改会被忽略,不会被同步回服务器。
# 文件在服务器端的后续更改会被同步到客户端,如果客户端也同时修改了这些文件,系统会生成冲突文件。
# seafile-ignore.txt 只能忽略还没有被同步的文件。对于已经被同步的文件,如果后来把它添加到 seafile-ignore.txt 中,系统只会忽略后续更改,已经上传的版本不会受影响。
### seafile-ignore.global.txt ###
# 自定义的后缀名,凡有 sfignore 后缀的都不进行同步
*.sfignore
*.sfignore/
*.sfignore.*
*.sfignore.*/
*.sfomit
*.sfomit.*
*.sfomit/
*.sfomit.*/
*.nosf
*.nosf.*
*.nosf/
*.nosf.*/
.DS_Store
*/.DS_Store
.thumbnails
*/.thumbnails
Thumbs.db
*/Thumbs.db
thumbs.db
*/thumbs.db
_desktop.ini
*/_desktop.ini
._*
*/._*
.$*
*/.$*
~$*
*/~$*
node_modules/
*/node_modules/
package-lock.json
pages4loader.json5
.deploy_git/
*/.deploy_git/
# HBuilder 目录
unpackage/
*/unpackage/
Icon
OneDrive/Icon
# wrangler project
.dev.vars*
*/.dev.vars*
.wrangler/
*/.wrangler/
### seafile-ignore.local.txt ###