How to realize the Analog Log Monitoring Interface of websocket by HTML
This article introduces the knowledge of "how to implement the analog log monitoring interface of websocket by HTML". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
[HTML] Analog Log Monitoring Interface of websocket
Simulate the interface effect of command line, use swoole as the service of websocket, and redo the interface effect of html.
SwLog Montior- vegetable field @ charset "utf-8"; body {background-color:#000; margin:0px; padding:0px; color:rgb (0je 1981.83); font: "Microsoft Yahei"; font-size:14px;} .window {border:2px # ccc outset; width:1200px; height:450px; background-color:rgb (20je 23pr 41); margin: 10px auto; overflow:hidden;} .title {background-color:#fff Padding:2px; color:#000;} # text {background-color:rgb; border-top:#ccc outset 2px; height:420px; overflow-y:scroll; padding:5px;} ul {margin:0px; padding:0px; list-style:none;} input {background-color:#000; border:0; color:#fff; outline:none; / * font-size:12px * / width:100%;} $(document) .ready (function () {var wsuri = "ws://192.168.1.102:9501"; var sock = new ReconnectingWebSocket (wsuri); sock.debug = true; sock.timeoutInterval = 5400; / / trigger sock.onopen = function () {console.log ("trigger connected to after connection establishment" + wsuri) $("ul") .append ("connected to" + wsuri+ "success");} / / trigger sock.onclose when closing a connection = function (e) {console.log ("trigger connection closed when closing a connection (" + e.code + ")"); $("ul") .append ("disconnected to" + wsuri+ "...") } / / trigger sock.onmessage = function (e) {console.log ("trigger message received after receiving the message:" + e.data); $("ul"). Append ("" + e.data + ""); var scrollHeight = $('# text'). Prop ("scrollHeight"); $('# text') .scrollTop (scrollHeight,420) } / / trigger sock.onerror=function (e) {console.log ("trigger on error" + wsuri); $("ul"). Append ("connected to" + wsuri+ "failed"); var scrollHeight = $('# text'). Prop ("scrollHeight"); $('# text') .scrollTop (scrollHeight,420) } $(document) .keyup (function (event) {if (event.keyCode = = 13) {$("ul"). Append ("."); var scrollHeight = $('# text'). Prop ("scrollHeight"); $('# text') .scrollTop (scrollHeight,420);});}) SwLog Montior Welcome... This is the end of the content of "how to implement the analog log monitoring interface of websocket by HTML". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!