Open Mobinkarimi1 opened 1 year ago
https://socket.io/docs/v4/namespaces/ How to Client initialization?
this packagee it's a Wrapper for socket.io-client-csharp, so you can look there for further info. according to: https://github.com/doghappy/socket.io-client-csharp/issues/112 you can do like this:
client = new SocketIOUnity("http://YOUR_SERVER_ADDRESS/your-namespace", new SocketIOOptions
{
...
});
This solution creates a new socket connection, which is not ideal at all I want to separate the application logic on a connection, for example, the login page has one namespace and the registration page has another namespace.
in the docs also they init multiple clients: https://socket.io/docs/v4/namespaces/#client-initialization
const socket = io("https://example.com"); // or io("https://example.com/"), the main namespace
const orderSocket = io("https://example.com/orders"); // the "orders" namespace
const userSocket = io("https://example.com/users"); // the "users" namespace
you may want to check with the library's documentation or reach out to the developer at https://github.com/doghappy/socket.io-client-csharp
در اسناد همچنین چندین مشتری را راه اندازی می کنند: https://socket.io/docs/v4/namespaces/#client-initialization
const socket = io("https://example.com"); // or io("https://example.com/"), the main namespace const orderSocket = io("https://example.com/orders"); // the "orders" namespace const userSocket = io("https://example.com/users"); // the "users" namespace
ممکن است بخواهید اسناد کتابخانه را بررسی کنید یا با توسعه دهنده در https://github.com/doghappy/socket.io-client-csharp تماس بگیرید
ok , thanks
your-namespace
io.in(my-namespace).emit("start game"); Apparently this solution is suitable, do you know how to use it in C#?
in your server and in your socket connection or in an event callback call the below line to make the client attached to a room (e.g: 'your-room')
// inside io.on('connection', (socket) => {...})
// or inside socket.on('im-in', data => {...}) <== but for this event to be triggered in you c# you have to call socket.Emit("im-in");
socket.join('your-room');
after this call emit when needed io.in('your-room').emit("start game");
can I use Dynamic namespace in client without create new socket connection? the Namespace property only has getter and I can't change it
Hi, how to connect to different namespaces? I have a problem using namespaces and implementing them in the client, how to implement them in the client Please help, any help would be helpful Thanks