Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coollaborative edition of schedules #165

Open
diogotvf7 opened this issue Jan 2, 2024 · 13 comments
Open

Coollaborative edition of schedules #165

diogotvf7 opened this issue Jan 2, 2024 · 13 comments

Comments

@diogotvf7
Copy link
Contributor

Why

It is very common for students to want to choose the same schedule as their friends. Therefore, there should be a way for users to edit their schedule options in a collaborative session with their friends.

References

@diogotvf7
Copy link
Contributor Author

diogotvf7 commented Jan 8, 2024

@thePeras
Copy link
Member

thePeras commented Jan 8, 2024

Maybe this is better for the server
https://github.com/django/channels

@Process-ing
Copy link
Contributor

About the debate of Socket.IO vs Django Channels for the backend, I feel that Socket.IO is the better alternative.

Django Channels is only useful if you are developing a pure Django (no Node.js) solution that should support multiple protocols. Since we are using Node.js and only care about WebSocket for the communication, this isn't very relevant. Socket.IO is also much more focused for real-time communication, which is exactly what we are after. It has multiple features for this end, like the rooms feature that we discussed in our meetings. Also note that Django Channels is not compatible with Socket.IO, so the frontend would have to use the standard WebSocket API.

Being the one that will work with the WebSocket communication (in issues #233 of the frontend and #89 of the backend), I will proceed with the Socket.IO API, but tell me your thoughts if you think Django Channels is better.

@tomaspalma
Copy link
Member

I agree with it, specially if by using django channels we would need to use raw websockets on the frontend, which would make the development experiente degraded.

@Process-ing
Copy link
Contributor

Apparently I discovered that the backend used Node.js, apparently not, my bad, but I still think it is best to setup Node.js to use Socket.IO.

And about the use of Socket.IO vs WebSocket on the frontend, I don't think that using WebSocket is worse for the programmer experience (I even think that the Socket.IO API is a little crappier xD), but it does not provide many of the features that makes Socket.IO so useful.

@tomaspalma
Copy link
Member

Apparently I discovered that the backend used Node.js, apparently not, my bad, but I still think it is best to setup Node.js to use Socket.IO.

Are you suggesting having a separate nodejs server for socketio apart from the django that we already have?

@Process-ing
Copy link
Contributor

Apparently I discovered that the backend used Node.js, apparently not, my bad, but I still think it is best to setup Node.js to use Socket.IO.

Are you suggesting having a separate nodejs server for socketio apart from the django that we already have?

Forget what I just said, the Node.js thing is related to the frontend, we just need to include Socket.IO from pip, again my bad.

@thePeras
Copy link
Member

Socket.io requires running a second instance among the already django server. For what it has to offer, I don't consider it worth. On the frontend part, we can easily create our own wrapper to attempt our needs.

If the backend was in node.js, I would immediately recommend socket.io, but since it's Django, we should follow its philosophy and resources.

@tomaspalma
Copy link
Member

tomaspalma commented Aug 20, 2024

When you say that it requires running a second instance are you talking about this part?

image

If so, this is also the standard way to do it in a nodejs server (to instantiate a socketio server instance)

@thePeras
Copy link
Member

When you say that it requires running a second instance are you talking about this part?

Yes.

The question is: Are we able to get authed user information from this approach? Also, are we able to get it by using Django channels?
If the answers are no in both questions, so let's use socket.io.
If is no to the first and yes to the second, we may need to discuss as this data can be useful, for example, to display the name and photo of the user.

@Process-ing
Copy link
Contributor

After digging more on this issue, I have to agree that creating a second instance for Socket.IO would probably be necessary, which isn't worth it. Ironically, the solution to that problem seems to be to also use Django Channels, in conjuction with Socket.IO, since it allows the Django HTTP methods to coexist with Socket.IO for WebSocket communication. This seems to be a popular approach and there are some guides explaining the setup (e.g. https://www.videosdk.live/developer-hub/socketio/django-socketio).

I still need to test this further, but I will keep this thread updated. If this ends up being the best solution, then this debate will not need to be continued, as both libraries and their functionalities will be available to the backend 🙌

@thePeras
Copy link
Member

Does AuthMiddlewareStack work with that approach?

To be honest, I would prefer using raw django channels only.

@tomaspalma
Copy link
Member

As stated here, using raw web sockets will require us to make a lot of functionality that is offered by socket.io, such as automatic reconnection, rooms and other features.

@Process-ing Since if socket io can be used with django channels and you are on the issue of setting up the web sockets on the backend, can you explore if we can use AuthMiddlewareStack that is a feature of django channels even if using socket io? Since this is starting to become more than just setup something, if you think you need help or another person to do this issue with you feel more than free to say so!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants