Replies: 2 comments 2 replies
-
Helo @zguig52 , You are correct, this wont work with the current way the code is structured, a new feature/patch would need to be added for this to be possible. A possible solution to this is to add support for hooks. In this case a postInitialization hook that accepts the io instance after instantiation and allows you to modify it before its attached to the actual strapi instance. Sample below // plugins.js
module.exports = ({ env }) => ({
// ...
io: {
enabled: true,
config: {
IOServerOptions: {
cors: { origin: "*", methods: ["GET"] },
},
contentTypes: {
message: "*",
chat: ["create"],
},
hooks: {
postIOInitialization: (io) => {
const pubClient = createClient({ url: "redis://localhost:6379" });
const subClient = pubClient.duplicate();
io.adapter(createAdapter(pubClient, subClient));
return io;
},
},
},
},
// ...
}); What do you think? Any suggestions? |
Beta Was this translation helpful? Give feedback.
2 replies
-
This is now possible in v2 via the init hook |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
First, thanks for this great work.
I am trying to configure the plugin to use @socket.io/redis-adapter (cluster mode case).
Official doc is here: https://socket.io/docs/v4/redis-adapter/
What I understood : it is needed to init additionnal objects from the redis-adapter lib and call an extra method once the io object is created (io.adapter(args)):
From what I saw in your conf file and source code, there is only the option to pass args during the "io = new Server()" init.
Have I missed something or is there an additionnal work required to add this support (like adding another field in options for the adapter type and so on)?
Do you see any way to make this work in the actual code status or shall I try to submit a patch to add support for external adapters?
Beta Was this translation helpful? Give feedback.
All reactions