CS3219-AY2324S1 / ay2324s1-course-assessment-g11

ay2324s1-course-assessment-g11 created by GitHub Classroom
MIT License
3 stars 2 forks source link

Collaboration Service - prototype text editor with websocket #19

Closed gycgabriel closed 1 year ago

gycgabriel commented 1 year ago

API

chunweii commented 1 year ago

I am not sure if I should access the editor through port 3000 or port 5001 (localhost:5001/test)?

It doesn't seem to work for port 3000 (localhost:3000/collab) and for port 5001, the basic feature works but whenever the user refreshes the page, the number of connections and disconnections increase. This is what I mean:

User connected: mIMnNMnLtUMtx6aoAAAZ
User connected: mIMnNMnLtUMtx6aoAAAZ
User connected: mIMnNMnLtUMtx6aoAAAZ
User disconnected: mIMnNMnLtUMtx6aoAAAZ
User disconnected: mIMnNMnLtUMtx6aoAAAZ
User disconnected: mIMnNMnLtUMtx6aoAAAZ
User connected: je1ZdPoVnuOhW_1hAAAb
User connected: je1ZdPoVnuOhW_1hAAAb
User connected: je1ZdPoVnuOhW_1hAAAb
User connected: je1ZdPoVnuOhW_1hAAAb
User disconnected: je1ZdPoVnuOhW_1hAAAb
User disconnected: je1ZdPoVnuOhW_1hAAAb
User disconnected: je1ZdPoVnuOhW_1hAAAb
User disconnected: je1ZdPoVnuOhW_1hAAAb
User connected: n7QbS7fwhwcak5fjAAAd
User connected: n7QbS7fwhwcak5fjAAAd
User connected: n7QbS7fwhwcak5fjAAAd
User connected: n7QbS7fwhwcak5fjAAAd
User connected: n7QbS7fwhwcak5fjAAAd
User disconnected: n7QbS7fwhwcak5fjAAAd
User disconnected: n7QbS7fwhwcak5fjAAAd
User disconnected: n7QbS7fwhwcak5fjAAAd
User disconnected: n7QbS7fwhwcak5fjAAAd
User disconnected: n7QbS7fwhwcak5fjAAAd
chunweii commented 1 year ago

I see why. Each time someone visits localhost:5001/test, the socket io connection listener starts, even if there are already event listeners doing the same thing before. Move the io.on("connection", ...) outside

ong6 commented 1 year ago

This is a prototype right - meaning that we're not going to merge this?

gycgabriel commented 1 year ago

I see why. Each time someone visits localhost:5001/test, the socket io connection listener starts, even if there are already event listeners doing the same thing before. Move the io.on("connection", ...) outside

Thanks for the catch. I suppose for the io listener calls within API calls I should use one-time listeners also

This is a prototype right - meaning that we're not going to merge this?

I assumed we were going to work on it iteratively, so we can merge this, and then polish it - code editor instead of text editor etc. the frontend I roughly made was just to check that it can be separated and it works across different localhosts, so that can be replaced as well

Testing

For testing I used Restman to send packets

  1. Send POST request to create session localhost:5001/session/create
  2. Type into it with localhost:5001/test
  3. Send POST request to save session localhost:5001/session/save