wynd — 5/10/2023, 3:13:25 PM

oh btw, anyone know how to use wasteof’s socketios with only the ws library, or do i have to use socket.io-client to like use the wasteof sockets. actcually which one has a bigger files size since i want my package use the least amount of dependencies.

currently we’re at 1 dependency, since fetchapi is in node now 🎉

♥ 7 ↩ 0 💬 13 comments

comments

asfsdgdfd:

How do you use wasteof’s socketios anyway? I am thinking about using the api for something…

5/10/2023, 8:12:00 PM
asfsdgdfd:

is there some docs or examples or something?

5/10/2023, 8:15:01 PM
wynd:
// i wrote this entirely from memory so there may be some syntax errors

import { io } from 'socket.io-client'
let socket = io('https://api.wasteof.money', { transports: ['websocket'], auth: { token: "BOT_TOKEN"} })

socket.on('updateMessageCount', count => {
    // fetch messages
})

socket.on('message', chatMessage => {
    // do something with the chat message
})
5/11/2023, 9:20:09 AM
asfsdgdfd:

How do I get the BOT_TOKEN part? Thanks!

5/11/2023, 2:21:10 PM
wynd:
// if you dont know what a fetch request is, this will be very hard to understand
await fetch(“https://api.wasteof.money/session“, {
    headers: {
        "Content-Type": "application/json"
    },
    body: JSON.stringify({ username: "USERNAME", password: "PASSWORD" }),
    method: “POST“,
})
.then(response=>response.json())
.then(data=>data.token || null)
5/11/2023, 2:29:12 PM
asfsdgdfd:

I do know what a fetch request is (I just didn’t know if BOT_TOKEN was some special token i didn’t have). This is very helpful though. Thanks!

5/11/2023, 2:46:23 PM
wynd:

oh yeah, its just a user tokem

5/11/2023, 2:48:49 PM
joebiden:

what the hell are you talking about

5/10/2023, 4:32:33 PM
oren:

you have to use socket.io-client

5/10/2023, 3:49:44 PM
wynd:

darn alright, thats fine i guess

5/10/2023, 4:28:50 PM
oren:

I mean, physically you could use ws, but you'd literally have to add in all the socket.io code. So it would end up the same

5/10/2023, 4:38:41 PM
wynd:

yeah but i could cut out a lot of unnecessary code, i’m probably just gonna use socketioclient

5/10/2023, 6:16:19 PM
radi8:

you need to use socketio, I think

5/10/2023, 3:49:30 PM