drashland / wocket

A WebSocket library for Deno
MIT License
104 stars 4 forks source link

fix: First client id being 0 #142

Closed ebebbington closed 2 years ago

ebebbington commented 2 years ago

Still works, just felt weird that the first clients id was 0, which can cause some edge cases as its a falsy value (say the user does a conditional on it)

ebebbington commented 2 years ago

I'm almost against having this trivial id scheme instead of a UUID for example. But for now, I fully agree that it shouldn't have 0 as an id for the stated reasons.

tbf maybe we just add the uuid now, but th best of both worlds:

for example

server.on('connect', e => {
  // also use `client`, to make it more descriptive that it is the id of the client, and not the packet
  console.log(e.detail.client.id, e.detail.client.uuid)
})
Guergeiro commented 2 years ago

Wouldn't totally be against the idea, although why do we need the "trivial" ID and not just the UUID as an ID?

ebebbington commented 2 years ago

Wouldn't totally be against the idea, although why do we need the "trivial" ID and not just the UUID as an ID?

It wouldn't make sense tbh... i just think a uuid would be too low level (i get it isnt really low level to start with, but compared to an id) for users of wocket, as bear in mind, a lot of people would be fairly new to dev or websockets when they work with these kind of modules

ebebbington commented 2 years ago

did this in #139