Commit 6be880e1 authored by wuhao's avatar wuhao 🎯

asder

parent bc753b29
Pipeline #4091 failed with stages
/*
* @Author: wuhao930406 1148547900@qq.com
* @Date: 2023-08-03 16:51:19
* @LastEditors: wuhao930406 1148547900@qq.com
* @LastEditTime: 2023-08-03 17:23:07
* @FilePath: /socketio_middleware/app/controller/home.js
* @Description:
*
* Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
*/
/* eslint-disable eqeqeq */ /* eslint-disable eqeqeq */
/* eslint-disable array-callback-return */ /* eslint-disable array-callback-return */
'use strict'; 'use strict';
...@@ -38,6 +48,7 @@ class HomeController extends Controller { ...@@ -38,6 +48,7 @@ class HomeController extends Controller {
}); });
} else { } else {
const index = id.indexOf(key); const index = id.indexOf(key);
console.log(io);
if (Array.isArray(id) && index !== -1) { if (Array.isArray(id) && index !== -1) {
io.emit('message', msg); io.emit('message', msg);
} else if (key === id) { } else if (key === id) {
......
/*
* @Author: wuhao930406 1148547900@qq.com
* @Date: 2023-08-03 16:51:19
* @LastEditors: wuhao930406 1148547900@qq.com
* @LastEditTime: 2023-08-03 17:16:43
* @FilePath: /socketio_middleware/config/config.default.js
* @Description:
*
* Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
*/
/* eslint valid-jsdoc: "off" */ /* eslint valid-jsdoc: "off" */
'use strict'; 'use strict';
...@@ -48,10 +58,10 @@ module.exports = appInfo => { ...@@ -48,10 +58,10 @@ module.exports = appInfo => {
}, },
}, },
redis: { redis: {
host: '192.168.40.2', host: 'localhost',
port: 6379, port: 6379,
auth_pass: 'nangao', // auth_pass: 'nangao',
db: 8, // db: 8,
}, },
}; };
......
/*
* @Author: wuhao930406 1148547900@qq.com
* @Date: 2023-08-03 16:51:19
* @LastEditors: wuhao930406 1148547900@qq.com
* @LastEditTime: 2023-08-03 17:15:13
* @FilePath: /socketio_middleware/config/plugin.js
* @Description:
*
* Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
*/
'use strict'; 'use strict';
// socket.io // socket.io
...@@ -5,3 +15,9 @@ exports.io = { ...@@ -5,3 +15,9 @@ exports.io = {
enable: true, enable: true,
package: 'egg-socket.io', package: 'egg-socket.io',
}; };
// cors
exports.cors = {
enable: true,
package: 'egg-cors',
};
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
}, },
"dependencies": { "dependencies": {
"egg": "^3", "egg": "^3",
"egg-cors": "^2.2.3",
"egg-scripts": "^2", "egg-scripts": "^2",
"egg-socket.io": "^4.1.6" "egg-socket.io": "^4.1.6"
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment