mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
Implemented RemoteEvent class
This commit is contained in:
parent
c3df679449
commit
913e9b067c
26
packages/app/src/classes/RemoteEvent/index.js
Normal file
26
packages/app/src/classes/RemoteEvent/index.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
export default class RemoteEvent {
|
||||||
|
constructor(id, payload) {
|
||||||
|
if (typeof id !== "string") {
|
||||||
|
console.error("Event id is required")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.id = id
|
||||||
|
this.payload = payload
|
||||||
|
|
||||||
|
this.send().catch((err) => {
|
||||||
|
console.error("Failed to send remote event >", err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
send = async () => {
|
||||||
|
app.cores.api.customRequest({
|
||||||
|
url: "/events/client",
|
||||||
|
method: "POST",
|
||||||
|
data: {
|
||||||
|
id: this.id,
|
||||||
|
payload: this.payload
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user