gaurishhs / elysia-ip

Get Client IP Address in Elysia
MIT License
53 stars 10 forks source link

How can i use it with websocket #7

Closed kwaitsing closed 9 months ago

kwaitsing commented 9 months ago
.ws('/api/nodeData', {
    message(ws) {
      setInterval(() => {
        ws.send(nodeData)
      }, 1000)
    }
  })

Where should i add it to?

gaurishhs commented 9 months ago

It should probably be in ws.data.ip https://elysiajs.com/patterns/websocket#message

kwaitsing commented 9 months ago

Ah great, thank you Post my code here in case someone need it

.ws('/api/upload/:servername/:key', {
    message(ws, message) {
      const { servername, key } = ws.data.params;
      ws.send(processNodeData(nodeData, message, servername, key, conf, ws.data.ip.address))
    }
  })