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
How do you use wasteof’s socketios anyway? I am thinking about using the api for something…
is there some docs or examples or something?
// 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
})
How do I get the BOT_TOKEN part? Thanks!
// 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)
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!
oh yeah, its just a user tokem
what the hell are you talking about
you have to use socket.io-client
darn alright, thats fine i guess
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
yeah but i could cut out a lot of unnecessary code, i’m probably just gonna use socketioclient
you need to use socketio, I think