CN101442515B - Remote control method based on browser - Google Patents
Remote control method based on browser Download PDFInfo
- Publication number
- CN101442515B CN101442515B CN2007100774110A CN200710077411A CN101442515B CN 101442515 B CN101442515 B CN 101442515B CN 2007100774110 A CN2007100774110 A CN 2007100774110A CN 200710077411 A CN200710077411 A CN 200710077411A CN 101442515 B CN101442515 B CN 101442515B
- Authority
- CN
- China
- Prior art keywords
- command
- server
- browser
- client
- operation command
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims abstract description 32
- 238000011161 development Methods 0.000 abstract description 7
- 238000005516 engineering process Methods 0.000 abstract description 5
- 230000000694 effects Effects 0.000 abstract description 3
- 238000012544 monitoring process Methods 0.000 abstract description 3
- 238000010586 diagram Methods 0.000 description 6
- 239000000284 extract Substances 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000013515 script Methods 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 1
- 238000013480 data collection Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 230000007774 longterm Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Images
Landscapes
- Information Transfer Between Computers (AREA)
- Computer And Data Communications (AREA)
Abstract
本发明适用于远端设备控制领域,提供了一种基于浏览器的远程控制方法,所述方法包括下述步骤:服务器接收从客户端的浏览器发出的操作命令,所述操作命令在JavaScript中生成一个Ajax对象;服务器在接收到操作命令后,将命令发到远方设备;服务器将远方设备返回的命令执行结果组织成一个执行结果对象,以JSON格式将该对象返回到客户端。客户端页面解析返回结果并显示。本发明实施结合使用了Ajax,JSON等web开发领域的最新技术,为在web上开发实时控制系统或数据监测系统提供了新的开发方法。该方法简单有效,能极大地简化程序流程,减少服务器负担,减少网络流量负载,并很好地改善客户操作体验和界面显示效果。
The present invention is applicable to the field of remote device control, and provides a remote control method based on a browser. The method includes the following steps: the server receives an operation command sent from the browser of the client, and the operation command is generated in JavaScript. An Ajax object; the server sends the command to the remote device after receiving the operation command; the server organizes the command execution result returned by the remote device into an execution result object, and returns the object to the client in JSON format. The client page parses and returns the result and displays it. The implementation of the present invention combines the latest technologies in the field of web development such as Ajax and JSON, and provides a new development method for developing a real-time control system or a data monitoring system on the web. The method is simple and effective, can greatly simplify program flow, reduce server load, reduce network traffic load, and greatly improve customer operation experience and interface display effect.
Description
技术领域technical field
本发明涉及远端设备控制领域,尤其涉及一种基于浏览器的远程控制方法。The invention relates to the field of remote device control, in particular to a browser-based remote control method.
背景技术Background technique
以往开发远程设备操作或实时数据采集系统时,大多采用C/S(client/server)结构开发软件。C/S是编程的一种模式:客户端加上服务器。客户端直接和服务器建立网络连接,向服务器发送命令,接收返回结果并显示。而现在软件开发逐渐向B/S(browser/server)结构演变。B/S结构的软件系统减少了在客户端安装软件的麻烦。In the past, when developing remote equipment operation or real-time data acquisition systems, most of them used C/S (client/server) structure to develop software. C/S is a mode of programming: client plus server. The client directly establishes a network connection with the server, sends commands to the server, receives and displays the returned results. Now software development is gradually evolving to a B/S (browser/server) structure. The software system of B/S structure reduces the trouble of installing software on the client side.
但是在B/S结构的软件中,尤其是异步的,长时间的操作,很难做好服务器端执行状态和客户端显示界面的同步。B/S结构的软件系统是基于无状态和非连接的,服务器端命令的执行状态无法推送到客户端显示。另外服务器端连续采集获取的数据也无法持续推送到客户端。这种时候只能通过刷新页面的方法重新向服务器端请求数据,并重新生成显示页面。这样做的一个问题是页面刷新闪烁比较频繁,而且要保持页面当前状态也比较困难。However, in software with B/S structure, especially asynchronous and long-term operations, it is difficult to synchronize the execution status of the server and the display interface of the client. The software system of the B/S structure is based on stateless and non-connection, and the execution status of the server-side commands cannot be pushed to the client-side for display. In addition, the data acquired continuously by the server cannot be continuously pushed to the client. At this time, the only way to re-request data from the server is by refreshing the page, and regenerate the display page. One problem with this is that the page refresh flickers more frequently, and it is more difficult to maintain the current state of the page.
发明内容Contents of the invention
本发明实施例的目的在于提供一种基于浏览器的远程控制方法,旨在通过使用同步或异步请求技术,在后台向服务器提起数据请求,完成操作命令,或者获得服务器连续返回的数据。The purpose of the embodiments of the present invention is to provide a browser-based remote control method, aiming at using synchronous or asynchronous request technology to submit a data request to the server in the background, complete the operation command, or obtain the data returned continuously by the server.
本发明实施是这样实现的,一种基于浏览器的远程控制方法,所述方法包括下述步骤:服务器接收从客户端的浏览器发出的操作命令,所述操作命令在JavaScript中生成一个Ajax对象;服务器在接收到操作命令后,将命令发到远方设备;及服务器将远方设备返回的执行结果组织成一个执行结果对象,以JSON格式将该对象返回到客户端;客户端Ajax对象在检测到服务器返回后,解析返回的JSON格式的数据,将命令执行结果对象还原并在浏览器上显示。The implementation of the present invention is achieved in this way, a browser-based remote control method, the method includes the following steps: the server receives an operation command sent from the browser of the client, and the operation command generates an Ajax object in JavaScript; After receiving the operation command, the server sends the command to the remote device; and the server organizes the execution result returned by the remote device into an execution result object, and returns the object to the client in JSON format; the client Ajax object detects that the server After returning, parse the returned data in JSON format, restore the command execution result object and display it on the browser.
本发明实施还提供一种基于浏览器的异步远程控制方法,其特征在于,所述方法包括下述步骤:服务器接收到命令请求后,生成命令对象,并放入待执行命令队列;服务器定时检测待执行命令队列中是否有命令对象,如有就逐个取出来执行,执行完毕把执行结果生成结果对象,放入执行完毕数据结果对象队列;服务器接收客户端的Ajax查询对象,检索结果对象队列,如果该队列中有结果对象,则将对象取出,按JSON格式发送给客户端。The implementation of the present invention also provides a browser-based asynchronous remote control method, which is characterized in that the method includes the following steps: After the server receives the command request, it generates a command object and puts it into the command queue to be executed; Whether there are command objects in the command queue to be executed, if there are, take them out one by one and execute them one by one. After the execution is completed, the execution result will generate a result object and put it into the data result object queue after execution; the server receives the Ajax query object from the client and retrieves the result object queue. If If there is a result object in the queue, the object will be taken out and sent to the client in JSON format.
本发明实施例结合使用了Ajax,JSON等web开发领域的最新技术,为开发web样式的实时控制系统或数据监测系统提供了新的开发方法。该方法简单有效,能极大地简化程序流程,减少服务器负担,减少网络流量负载,并很好地改善客户操作体验和界面显示效果。The embodiment of the present invention combines the latest technologies in the field of web development such as Ajax and JSON to provide a new development method for developing a web-style real-time control system or data monitoring system. The method is simple and effective, can greatly simplify program flow, reduce server load, reduce network traffic load, and greatly improve customer operation experience and interface display effect.
附图说明Description of drawings
图1示出了本发明实施例基于浏览器的远程控制方法的执行一个同步命令时的架构示意图;FIG. 1 shows a schematic diagram of a browser-based remote control method in an embodiment of the present invention when executing a synchronization command;
图2示出了本发明实施例基于浏览器的远程控制方法的定时执行异步命令刷新数据的架构示意图;FIG. 2 shows a schematic diagram of an architecture of timing execution of an asynchronous command to refresh data in a browser-based remote control method according to an embodiment of the present invention;
图3示出了本发明实施例基于浏览器的远程控制方法的执行批量异步命令时的架构示意图。FIG. 3 shows a schematic diagram of a browser-based remote control method according to an embodiment of the present invention when executing a batch of asynchronous commands.
具体实施方式Detailed ways
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。In order to make the object, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.
在对本发明实施例进行阐述之前,对本发明实施例所涉及的概念进行介绍:Before describing the embodiments of the present invention, the concepts involved in the embodiments of the present invention are introduced:
JavaScript:Javascript就是一种嵌入到网页Html代码中的,可在浏览器客户端运行的一种用于开发动态网页的编程语言。JavaScript: Javascript is a programming language that is embedded in the Html code of a web page and can be run on a browser client for developing dynamic web pages.
xmlHttpRequest:可在JavaScript中创建的客户端ActiceX对象,使用该对象可向服务器发起请求,获取数据。xmlHttpRequest: A client-side ActiceX object that can be created in JavaScript, using this object to initiate a request to the server to obtain data.
Ajax:是Asynchronous JavaScript and XML(异步JavaScript和XML)的缩写,是指一种创建交互式网页应用的网页开发技术,其中主要使用了xmlHttpRequest对象。Ajax: It is the abbreviation of Asynchronous JavaScript and XML (asynchronous JavaScript and XML), which refers to a web development technology for creating interactive web applications, in which the xmlHttpRequest object is mainly used.
XML:是eXtensible Markup Language(扩展标记语言)的缩写。XML是一种简单的数据存储语言,使用一系列简单的标记描述数据。简单来说就是一种描述数据结构的格式。XML: It is the abbreviation of eXtensible Markup Language (Extensible Markup Language). XML is a simple data storage language that describes data using a series of simple tags. Simply put, it is a format for describing data structures.
JSON:是JavaScript Object Notation(JavaScript原生对象)是一种轻量级的数据交换格式。它基于JavaScript Programming Language。JSON采用完全独立于语言的文本格式。JSON和XML类似,也是一种描述数据结构的格式,但在JavaScript中使用时比XML更简单方便。JSON: JavaScript Object Notation (JavaScript native object) is a lightweight data exchange format. It is based on JavaScript Programming Language. JSON is in a text format that is completely language independent. JSON, similar to XML, is also a format for describing data structures, but it is simpler and more convenient than XML when used in JavaScript.
图1示出了本发明实施例基于浏览器的远程控制方法的执行同步命令时的架构示意图,现详述如下:FIG. 1 shows a schematic diagram of the architecture of the browser-based remote control method of the embodiment of the present invention when executing a synchronization command, which is now described in detail as follows:
操作员在浏览器网页上提起一个操作命令,JavaScript中生成一个Ajax对象,向服务器发起一个同步请求,可附带命令参数。请求发出后在当前网页上显示一个命令正在执行的执行等待提示。The operator raises an operation command on the browser webpage, an Ajax object is generated in JavaScript, and a synchronous request is sent to the server, which may include command parameters. After the request is sent, a command execution waiting prompt is displayed on the current web page.
服务器接收到命令请求后,从请求数据中提取命令参数,然后通过通讯通道将命令发送到远方设备。After receiving the command request, the server extracts the command parameters from the request data, and then sends the command to the remote device through the communication channel.
远方设备执行命令,返回执行结果给服务器。The remote device executes the command and returns the execution result to the server.
服务器将执行结果组织成一个执行结果对象,其中包含命令执行结果,执行时间,执行失败的错误提示信息等,然后以JSON格式将该对象返回到客户端。The server organizes the execution result into an execution result object, which includes the command execution result, execution time, error message of execution failure, etc., and then returns the object to the client in JSON format.
客户端Ajax对象检测到服务器执行完毕返回,首先关闭显示命令正在执行的对话框,然后调用一个JavaScript回调函数解析返回的JSON格式的数据,将命令执行结果对象还原。根据执行结果显示命令执行成功。或者显示命令执行失败及错误提示信息。The client-side Ajax object detects that the server returns after execution, first closes the dialog box showing that the command is being executed, then calls a JavaScript callback function to parse the returned data in JSON format, and restores the command execution result object. According to the execution result, the command execution is successful. Or display command execution failure and error message.
图2示出了本发明实施例基于浏览器的远程控制方法的定时执行异步命令刷新数据的架构示意图,现详述如下:FIG. 2 shows a schematic diagram of the structure of the regularly executed asynchronous command refresh data of the browser-based remote control method of the embodiment of the present invention, which is now described in detail as follows:
在JavaScript脚本中创建一个定时器,定时调用Ajax对象向服务器发起查询实时数据的异步请求。Create a timer in the JavaScript script, and call the Ajax object regularly to initiate an asynchronous request to the server for querying real-time data.
服务器接收到命令请求后,对远方设备进行实时数据召测。如果设备自动定时上传实时数据到服务器内存中,也可从服务器内存数据中取出最新数据返回。After the server receives the command request, it conducts a real-time data call test on the remote device. If the device automatically and regularly uploads real-time data to the server memory, it can also retrieve the latest data from the server memory data and return it.
服务器将数据集合对象以JSON格式返回到客户端。The server returns the data collection object to the client in JSON format.
客户端Ajax对象检测到服务器执行完毕返回,调用一个JavaScript回调函数解析返回的JSON格式的数据。如果查询数据成功,则刷新界面上的数据区。The client-side Ajax object detects that the server has finished executing and returns, and calls a JavaScript callback function to parse the returned data in JSON format. If the query data is successful, refresh the data area on the interface.
图3示出了本发明实施例基于浏览器的远程控制方法的执行批量异步命令时的架构示意图,现详述如下:FIG. 3 shows a schematic diagram of the architecture of the browser-based remote control method of the embodiment of the present invention when executing a batch of asynchronous commands, which are now described in detail as follows:
操作员在浏览器页面上提起一个操作命令,JavaScript中生成一个Ajax对象,向服务器发起一个异步请求,该操作命令可附带命令参数。发送完毕后该页面即可关闭。The operator raises an operation command on the browser page, an Ajax object is generated in JavaScript, and an asynchronous request is initiated to the server, and the operation command can be accompanied by command parameters. The page can be closed after sending.
服务器接收到操作命令后,从请求数据中提取命令参数,然后生成命令对象,并放入待执行命令队列。After the server receives the operation command, it extracts the command parameters from the request data, then generates a command object, and puts it into the command queue to be executed.
服务器的命令调度执行程序定时检测待执行队列中是否有命令,如有就逐个取出来执行。执行完毕把执行结果(可携带数据)生成结果对象,放入执行完毕数据结果对象队列。The command scheduling execution program of the server regularly detects whether there are commands in the queue to be executed, and if so, takes them out one by one for execution. After the execution is completed, the execution result (portable data) is generated into a result object and put into the queue of the executed data result object.
客户端的另一个显示异步命令执行结果的网页定时异步调用Ajax对象,向服务器检索结果对象队列,如果该队列中有结果对象,则服务器将对象取出,按JSON格式返回给客户端。Another webpage on the client side that displays the execution results of asynchronous commands calls the Ajax object asynchronously at regular intervals to retrieve the result object queue from the server. If there is a result object in the queue, the server takes the object out and returns it to the client in JSON format.
客户端Ajax对象检测到服务器返回,从JSON格式的返回数据中判断是否有返回数据。如有,则将命令执行结果逐个写入到网页中,同时可播放声音,显示动画等提醒操作员有异步命令执行完毕。The client Ajax object detects the return from the server, and judges whether there is return data from the return data in JSON format. If so, the command execution results are written to the web page one by one, and at the same time, it can play sound, display animation, etc. to remind the operator that the asynchronous command has been executed.
本发明实施例所采用的浏览器指IE6浏览器,但不限于在其他浏览器(如firefox),在其他浏览器中实现的时候部分JavaScript脚本可能不同。The browser used in the embodiment of the present invention refers to the IE6 browser, but is not limited to other browsers (such as firefox), and some JavaScript scripts may be different when implemented in other browsers.
本发明结合使用了Ajax,JSON等web开发领域的最新技术,为在web上开发实时控制系统或数据监测系统提供了新的开发方法。该方法简单有效,能极大地简化程序流程,减少服务器负担,减少网络流量负载,并很好地改善客户操作体验和界面显示效果。The present invention combines the latest technologies in the field of web development such as Ajax and JSON, and provides a new development method for developing a real-time control system or a data monitoring system on the web. The method is simple and effective, can greatly simplify program flow, reduce server load, reduce network traffic load, and greatly improve customer operation experience and interface display effect.
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention should be included in the protection of the present invention. within range.
Claims (8)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2007100774110A CN101442515B (en) | 2007-11-22 | 2007-11-22 | Remote control method based on browser |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2007100774110A CN101442515B (en) | 2007-11-22 | 2007-11-22 | Remote control method based on browser |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101442515A CN101442515A (en) | 2009-05-27 |
CN101442515B true CN101442515B (en) | 2011-09-07 |
Family
ID=40726759
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN2007100774110A Expired - Fee Related CN101442515B (en) | 2007-11-22 | 2007-11-22 | Remote control method based on browser |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101442515B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8887173B2 (en) | 2009-12-22 | 2014-11-11 | Echostar Global B.V. | Method and system for communicating between computing devices |
Families Citing this family (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102523309A (en) * | 2009-07-31 | 2012-06-27 | 同方威视技术股份有限公司 | Method and equipment for responding request of client side and acquiring and returning real-time data |
CN101917286B (en) * | 2010-07-30 | 2013-01-02 | 上海普元信息技术股份有限公司 | Web performance analysis system and method for realizing cross-browser in internet application system |
CN102820980B (en) * | 2011-06-08 | 2018-11-06 | 南京中兴新软件有限责任公司 | A kind of device and method of transmitting order to lower levels |
CN102279884B (en) * | 2011-08-05 | 2015-04-01 | 中国工商银行股份有限公司 | Data acquiring and displaying method, system and Web server based on Web pages |
CN102426549B (en) * | 2011-09-08 | 2013-06-26 | 新一站保险代理有限公司 | Efficient Web form validation method and framework thereof |
CN104135536A (en) * | 2014-08-15 | 2014-11-05 | 浪潮电子信息产业股份有限公司 | Data interaction method of Web management system based on Json data protocols |
CN106293714B (en) * | 2016-07-29 | 2020-01-14 | 四川天邑康和通信股份有限公司 | Data layer-based method for improving ajax performance |
CN106506565B (en) * | 2017-01-04 | 2020-01-07 | 上海上讯信息技术股份有限公司 | Remote command execution method and device |
CN108647015A (en) * | 2018-05-08 | 2018-10-12 | 深圳市智汇牛科技有限公司 | A kind of man-machine interactive system framework in automatic kitchen field |
CN109032583B (en) * | 2018-07-25 | 2022-06-17 | 北京小米移动软件有限公司 | Data interaction method and device |
CN110175055B (en) * | 2019-05-07 | 2022-02-18 | 成都交大光芒科技股份有限公司 | Service-based browser and fingerprint instrument calling method |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP0917052A1 (en) * | 1997-11-17 | 1999-05-19 | International Business Machines Corporation | Method and apparatus for interacting with hardware devices remotely |
CN1474558A (en) * | 2002-08-19 | 2004-02-11 | 乐金电子(天津)电器有限公司 | Household network system |
CN1987850A (en) * | 2005-12-20 | 2007-06-27 | 腾讯科技(深圳)有限公司 | Method for realizing AJAX webpage |
-
2007
- 2007-11-22 CN CN2007100774110A patent/CN101442515B/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP0917052A1 (en) * | 1997-11-17 | 1999-05-19 | International Business Machines Corporation | Method and apparatus for interacting with hardware devices remotely |
CN1474558A (en) * | 2002-08-19 | 2004-02-11 | 乐金电子(天津)电器有限公司 | Household network system |
CN1987850A (en) * | 2005-12-20 | 2007-06-27 | 腾讯科技(深圳)有限公司 | Method for realizing AJAX webpage |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8887173B2 (en) | 2009-12-22 | 2014-11-11 | Echostar Global B.V. | Method and system for communicating between computing devices |
Also Published As
Publication number | Publication date |
---|---|
CN101442515A (en) | 2009-05-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101442515B (en) | Remote control method based on browser | |
US8245125B1 (en) | Hybrid rendering for webpages | |
CN108595304B (en) | Webpage monitoring method and device | |
JP4878627B2 (en) | Initial server-side content rendering for client script web pages | |
US10540417B2 (en) | Determining web page processing state | |
US9130975B2 (en) | Generation of macros | |
US9961129B2 (en) | Business transaction correlation with client request monitoring data | |
US11055085B2 (en) | Method, apparatus, and system for hot-deploying application | |
US8239491B1 (en) | Content request optimization | |
US20110252305A1 (en) | Capturing the visual content of browser windows | |
US20160057220A1 (en) | System for cloud computing using web components | |
US20150248302A1 (en) | Method, apparatus, server and system for implementing web application | |
CN104967542B (en) | A kind of test method, the device and system of the mobile terminal page | |
CN105100203B (en) | Show the method and terminal of monitoring data | |
CN111159039A (en) | Service simulation method, system, device and storage medium | |
CN103237048A (en) | Real-time warning system and real-time warning method of B/S framework in electrical power system | |
US20130124971A1 (en) | Real time web script refresh using asynchronous polling without full web page reload | |
CN105608078B (en) | A kind of method and apparatus of Webpage live preview | |
CN111666199B (en) | Debugging method executed on intelligent terminal and software debugger | |
US9779176B2 (en) | Accessing external functionality within a component-based web application | |
US8667090B2 (en) | Delivering a webpage to a client | |
US20180103114A1 (en) | Display control method, display control device, and recording medium | |
CN109309874B (en) | Focus updating method and device | |
KR101863745B1 (en) | Fire engine pump monitoring and control system using web server and the method thereof | |
KR101872773B1 (en) | Fire engine pump monitoring and control system using mobile communication terminal and the method thereof |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
C17 | Cessation of patent right | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20110907 Termination date: 20131122 |