current position:Home>Why can webscoket be used without a defined method? What is the principle?

Why can webscoket be used without a defined method? What is the principle?

2022-08-06 07:36:47CSDN Q&A

I don't understand this part because I read the code written by others.Isn't webscoket only four built-in methods, onopen, onmessage, onerror, and onclose.
Here this $openws.ws is an instance of webscoket.But I saw that there is no chat_receipt method in the code at all, so why can it still be used? The backend has the same method name. Does it mean that webscoket can directly call the method determined by the backend through the instance, so even if it is connected, and then the backend can automatically push to the foreground by doing operations in this method?

img


Instances are like this.There is no such method at all

img

copyright notice
author[CSDN Q&A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/218/202207301624418037.html

Random recommended