Js operations are like this: {code...} is there any js interface? js operations are like this.
Ws = new WebSocket ($ ("# uri "). val (); // response to ws after the connection is established successfully. onopen = function () {}// response to ws after receiving the Server Message. onmessage = function (e) {}// response to ws after the connection is closed. onclose = function () {ws = null ;}
Is there any js interface?
Reply content:
This is the case for js operations.
Ws = new WebSocket ($ ("# uri "). val (); // response to ws after the connection is established successfully. onopen = function () {}// response to ws after receiving the Server Message. onmessage = function (e) {}// response to ws after the connection is closed. onclose = function () {ws = null ;}
Is there any js interface?
Websocket is only a persistent connection communication protocol and does not provide actual service functions.
The transmitted content must be negotiated by both parties (both the frontend and backend) to determine how to obtain fields such as the type and content. after the information is agreed, data is encapsulated and parsed.
Generally, websocket is suitable for transmitting text data. although The protocol also stipulates that binary data can be transmitted, JS cannot handle binary data. Therefore, we need to encode binary data into text data. There are many such methods, such as base64, and then send it to the system. The answer on the first floor is also very good and clear. I think the landlord is not very clear about the protocol and so on. I suggest you read more books in this regard. it plays a very role in improving the programming level.