jchomko / a-heart-from-space

0 stars 0 forks source link

multiple sessions #6

Open anatolysukhanov opened 4 years ago

anatolysukhanov commented 4 years ago

Allow multiple sessions to be run simultaneously from the website - join a group with a numerical code or geolocation.

jchomko commented 4 years ago

It seems the easiest way to run this would be to have users make their own session, and then share that session ID with others. A more advanced approach would detect nearby sessions and ask a user if they want to join that open session?

anatolysukhanov commented 4 years ago

What would be the effect of joining a session?

jchomko commented 4 years ago

The idea is that if two or more groups of people want to use the website at the same time, that there should be some way for the groups to not interfere with each other. I think this could be done using the 'rooms' feature in socket.io: https://socket.io/docs/rooms/

anatolysukhanov commented 4 years ago

The idea is that if two or more groups of people want to use the website at the same time, that there should be some way for the groups to not interfere with each other.

So each group would be building its own heart shape?

jchomko commented 4 years ago

Yeah exactly!

anatolysukhanov commented 4 years ago

It seems the easiest way to run this would be to have users make their own session, and then share that session ID with others. A more advanced approach would detect nearby sessions and ask a user if they want to join that open session?

I think this could be done using the 'rooms' feature in socket.io: https://socket.io/docs/rooms/

So on app start the user would be presented with the choice to either start their own socket room or join an existing one (select it from a list of all rooms or just use the nearest one)?

jchomko commented 4 years ago

Yeah exactly.

On Wed, Aug 5, 2020 at 4:43 PM Anatoly Sukhanov notifications@github.com wrote:

It seems the easiest way to run this would be to have users make their own session, and then share that session ID with others. A more advanced approach would detect nearby sessions and ask a user if they want to join that open session?

I think this could be done using the 'rooms' feature in socket.io: https://socket.io/docs/rooms/

So on app start the user would be presented with the choice to either start their own socket room or join an existing one (select it from a list of all rooms or just use the nearest one)?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jchomko/a-heart-from-space/issues/6#issuecomment-669496819, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5IHUVGVNSFZA6UMXYPWOTR7G75RANCNFSM4OF74PRA .

-- Jonathan Chomko jonathanchomko.com http://www.jonathanchomko.com +1 438 888 2114

jchomko commented 4 years ago

Hey, have you had any time to look at this?

anatolysukhanov commented 4 years ago

Sorry for delay on this. I started implementing it locally, but stopped at some point having thought you might have lost interest in the project (I have experienced similar situations). I should have asked clearly.

anatolysukhanov commented 4 years ago

Anyway, I had some questions. I will get back to you on that later today.

jchomko commented 4 years ago

Hey, no worries, yeah I was away for some of August. I'm still developing it but I think this will be the last module to do!

anatolysukhanov commented 4 years ago

A more advanced approach would detect nearby sessions and ask a user if they want to join that open session?

What would be the location of a session? The centroid of the users' locations in a group?

jchomko commented 4 years ago

yeah the centroid of the group makes sense!

anatolysukhanov commented 4 years ago

Added the ability to see a list of existing rooms or socket ids ("each socket automatically joins a room identified by its own id"): 92e594f7005f44ef002c57d538806bd488309e4c. When a tab (browser) is closed, the id dissappers from the list. When a new tab is opened, a new id gets added to the list.

image

Will add more functionality later today.

jchomko commented 4 years ago

Ok looks like a good start!

anatolysukhanov commented 4 years ago
function sendGroupCoordinates() {
  if (coordinatesChanged) {
    coordinatesChanged = false;
    io.emit("receive-group-coordinates", groupCoords);
  }
}

setInterval(sendGroupCoordinates, 150);

Would it make more sense to emit only the coordinates of the sender to the rest of a room in response to update-coordinates?

Something like this

socket.on("update-coordinates", function (coords) {
    ...
  socket.to("room").emit("update-coordinates", {id: socket.id, coords});
}
jchomko commented 4 years ago

Hey, yeah that might be more efficient! But currently I re-draw the line on each update so I don't imagine it would make that much of a difference, unless I change my line drawing code as well.

jchomko commented 4 years ago

Hey, just coming back to this now, sorry for the slow follow up. It seems that the room joining code works pretty well, thanks for this.

The aim of the rooms is for a user to only see the points of those who are also in the same room as them - would you be able to update the rest of the code to reflect this? Let me know how much time you'd estimate this would take. I could also do it from what you've done already if things are busy for you!

anatolysukhanov commented 4 years ago

The aim of the rooms is for a user to only see the points of those who are also in the same room as them - would you be able to update the rest of the code to reflect this? Let me know how much time you'd estimate this would take. I could also do it from what you've done already if things are busy for you!

I will try to finish it early next week. Should be done within one working day.

jchomko commented 4 years ago

Okay great, keep me posted with any questions!

anatolysukhanov commented 4 years ago

Okay great, keep me posted with any questions!

When Fill is On, you draw a triangle connecting what exactly?

jchomko commented 4 years ago

The fill is a triangle that goes between the centroid, your point and the point beside you - it's used so that the users can signal that they're satisfied with the shape of the heart; when all users are satisfied, all the triangles make a solid heart. It might not be fully implemented on this branch though, so you don't need to worry about it - as long as the right data is being sent to the right rooms I can update the rest.

anatolysukhanov commented 4 years ago

I finally was able to put everything together in a new branch. Please check it out:

https://github.com/jchomko/a-heart-from-space/tree/sessions

It might not be fully implemented on this branch though, so you don't need to worry about it - as long as the right data is being sent to the right rooms I can update the rest.

OK. This part is commented out. I've also commented out most of your code. Don't kill me for that.

anatolysukhanov commented 4 years ago

https://github.com/jchomko/a-heart-from-space/pull/8

jchomko commented 4 years ago

Hey, this looks good, thank you - it's also a good model for how I should structure my code! No worries about the commenting out - I've made a bunch of other updates in other branches so I'll probably just combine them manually.