mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 10:34:17 +00:00
rename socket to client
This commit is contained in:
parent
afa05b3bfc
commit
eb450809d7
@ -123,7 +123,7 @@ class Server {
|
|||||||
//* register controllers
|
//* register controllers
|
||||||
await this.initializeControllers()
|
await this.initializeControllers()
|
||||||
|
|
||||||
// initialize socket.io
|
// initialize main socket
|
||||||
this.wsInterface.io.on("connection", this.handleWSClientConnection)
|
this.wsInterface.io.on("connection", this.handleWSClientConnection)
|
||||||
|
|
||||||
// initialize http server
|
// initialize http server
|
||||||
@ -343,41 +343,41 @@ class Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleWSClientConnection = async (socket) => {
|
handleWSClientConnection = async (client) => {
|
||||||
socket.res = (...args) => {
|
client.res = (...args) => {
|
||||||
socket.emit("response", ...args)
|
client.emit("response", ...args)
|
||||||
}
|
}
|
||||||
socket.err = (...args) => {
|
client.err = (...args) => {
|
||||||
socket.emit("responseError", ...args)
|
client.emit("responseError", ...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof this.params.onWSClientConnection === "function") {
|
if (typeof this.params.onWSClientConnection === "function") {
|
||||||
await this.params.onWSClientConnection(socket)
|
await this.params.onWSClientConnection(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
for await (const [nsp, on, dispatch] of this.wsInterface.eventsChannels) {
|
for await (const [nsp, on, dispatch] of this.wsInterface.eventsChannels) {
|
||||||
socket.on(on, async (...args) => {
|
client.on(on, async (...args) => {
|
||||||
try {
|
try {
|
||||||
await dispatch(socket, ...args).catch((error) => {
|
await dispatch(client, ...args).catch((error) => {
|
||||||
socket.err({
|
client.err({
|
||||||
message: error.message,
|
message: error.message,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
socket.err({
|
client.err({
|
||||||
message: error.message,
|
message: error.message,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on("ping", () => {
|
client.on("ping", () => {
|
||||||
socket.emit("pong")
|
client.emit("pong")
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on("disconnect", async () => {
|
client.on("disconnect", async () => {
|
||||||
if (typeof this.params.onWSClientDisconnect === "function") {
|
if (typeof this.params.onWSClientDisconnect === "function") {
|
||||||
await this.params.onWSClientDisconnect(socket)
|
await this.params.onWSClientDisconnect(client)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user