drashland / wocket

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

feat: Support query parameters #139

Closed ebebbington closed 2 years ago

ebebbington commented 2 years ago
server.on('connect', e => {
  console.log(e.detail.queryParams.get('name'))
})

Reason it was like this, is because every client connection could use different params, so we need to set the parameters per connection, meaning we can't just do this.queryParams = url.searchParams because it will be overridden when a new connection comes in

Alternatively, we could add it to the client map:

clients.set(id, {
  socket,
  queryParams: url.queryParams
})

server.on('check google', e => {
  // ok so the client uses query params to check a specific google site, now im finally gonna use it
  const client = server.clients.get(e.detail.id)
  const site = client.queryParams.get("site")
})
ebebbington commented 2 years ago

wil change branch when the paths pr is merged

crookse commented 2 years ago

sorry i was super late on this. i would review it then stop, then come back and forget what i reviewed, then stop. finally have some little time to spare.