[go: up one dir, main page]

CN101854371B - The method called and process of JavaScript object, device - Google Patents

The method called and process of JavaScript object, device Download PDF

Info

Publication number
CN101854371B
CN101854371B CN200910106428.3A CN200910106428A CN101854371B CN 101854371 B CN101854371 B CN 101854371B CN 200910106428 A CN200910106428 A CN 200910106428A CN 101854371 B CN101854371 B CN 101854371B
Authority
CN
China
Prior art keywords
remote
javascript
name
remote object
request message
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.)
Active
Application number
CN200910106428.3A
Other languages
Chinese (zh)
Other versions
CN101854371A (en
Inventor
张�杰
符海芳
金洪波
钟炜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Changshu Intellectual Property Operation Center Co ltd
Guangdong Gaohang Intellectual Property Operation Co ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN200910106428.3A priority Critical patent/CN101854371B/en
Publication of CN101854371A publication Critical patent/CN101854371A/en
Application granted granted Critical
Publication of CN101854371B publication Critical patent/CN101854371B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Transfer Between Computers (AREA)

Abstract

本发明实施例涉及通信和互联网领域,揭露了一种JavaScript对象处理的方法,该包括步骤:接收客户端发送的远程调用请求消息;解析所述远程调用请求消息,获得业务逻辑信息;根据所述业务逻辑信息进行业务处理;将处理后的结果进行消息结构封装并向所述客户端发送。同时还提供了实现上述方法的装置及JavaScript对象调用的方法和装置。该方法和装置达到了JavaScript远程方法调用的效果,客户端与服务器端配合的方式执行JavaScript对象,从而可以免除从远程下载js文件的步骤,当业务逻辑复杂,或者JavaScript业务文件大时,此方法将带来明显优势,能够更好的满足用户体验上的要求。

The embodiment of the present invention relates to the fields of communication and the Internet, and discloses a method for processing JavaScript objects, which includes the steps of: receiving a remote call request message sent by a client; parsing the remote call request message to obtain business logic information; according to the The business logic information is processed; the processed result is encapsulated in a message structure and sent to the client. At the same time, a device for realizing the above method and a method and device for invoking JavaScript objects are also provided. The method and device achieve the effect of JavaScript remote method invocation, and the client and server cooperate to execute JavaScript objects, thereby eliminating the step of downloading js files from a remote location. When the business logic is complex or the JavaScript business file is large, this method It will bring obvious advantages and better meet the requirements of user experience.

Description

JavaScript对象的调用及处理的方法、装置Method and device for invoking and processing JavaScript objects

技术领域 technical field

本发明实施例涉及通信和互联网领域,尤其设计一种JavaScript对象的调用及处理方法、装置。The embodiments of the present invention relate to the fields of communication and the Internet, and in particular design a method and device for invoking and processing JavaScript objects.

背景技术 Background technique

近年来移动嵌入式设备发展迅猛,人们通过移动设备访问网络的需求随之增强,要求尽可能便捷的访问互联网。JavaScript技术逐渐被广泛应用于WEB开发。JavaScript技术是隐藏在web内容呈现(如网页、widget)背后的关键技术之一。JavaScript技术是基于对象的脚步语言,核心JavaScript包括一个核心的对象集合,其中有Array、Data、Math等,还有一些核心的语法元素,如运算符、控制结构和语句等。In recent years, with the rapid development of mobile embedded devices, people's demand for accessing the network through mobile devices has increased, and it is required to access the Internet as conveniently as possible. JavaScript technology is gradually being widely used in WEB development. JavaScript technology is one of the key technologies hidden behind the presentation of web content (such as web pages, widgets). JavaScript technology is an object-based scripting language. The core JavaScript includes a core set of objects, including Array, Data, Math, etc., as well as some core grammatical elements, such as operators, control structures, and statements.

起初移动嵌入式设备(如手机)访问互联网的方式虽然某种程度上能够做到这一点(如WAP),但其呈现形势过于简单,不足以满足用户体验上的要求。在用户体验与业务类型方面造成了一定的困难。Although the way in which mobile embedded devices (such as mobile phones) access the Internet can do this to some extent (such as WAP), its presentation is too simple to meet the requirements of user experience. It has caused certain difficulties in terms of user experience and business types.

发明内容 Contents of the invention

本发明实施例提供一种JavaScript对象的调用方法,改进JavaScript的执行方式,使得JavaScript对象由客户端与服务器端配合执行,提升终端用户的体验效果。The embodiment of the present invention provides a method for invoking a JavaScript object, and improves the execution mode of JavaScript, so that the JavaScript object is executed by the client and the server in cooperation, thereby improving the experience effect of the terminal user.

本发明实施例提供的JavaScript对象的调用方法包括步骤:The calling method of the JavaScript object that the embodiment of the present invention provides comprises steps:

接收客户端发送的远程调用请求消息;Receive the remote call request message sent by the client;

解析所述远程调用请求消息,获得业务逻辑信息;Analyzing the remote call request message to obtain business logic information;

根据所述业务逻辑信息进行业务处理;Perform business processing according to the business logic information;

将处理后的结果进行消息结构封装并向所述客户端发送。Encapsulate the processed result in a message structure and send it to the client.

本发明实施例提供一种JavaScript对象调用的方法,该方法包括:An embodiment of the present invention provides a method for invoking a JavaScript object, the method comprising:

对JavaScript的代码文件进行词法分析和语法分析,获得远程对象名;Perform lexical analysis and syntax analysis on the JavaScript code file to obtain the remote object name;

当JavaScript对象与字符集中远程对象匹配成功后生成发送远程调用请求消息,该远程调用请求消息中携带所述远程对象名;When the JavaScript object is successfully matched with the remote object in the character set, a remote call request message is generated and sent, and the remote call request message carries the name of the remote object;

向服务器端发送所述远程调用请求消息;Send the remote call request message to the server;

接收服务器端的处理结果,所述处理结果通过处理所述远程调用请求消息获得,对结果进行解析后继续执行JavaScript代码。Receive the processing result at the server end, the processing result is obtained by processing the remote call request message, and continue to execute the JavaScript code after parsing the result.

进一步,本发明实施例还提供一种服务器端装置,其包括Further, an embodiment of the present invention also provides a server-side device, which includes

一种服务器,其特征在于,所述服务器包括:A server, characterized in that the server includes:

接收单元,用于接收客户端发送的远程调用请求消息。The receiving unit is configured to receive the remote call request message sent by the client.

解析单元,用于解析接收单元接收远程调用请求消息,获得业务逻辑信息。The parsing unit is configured to parse the remote call request message received by the receiving unit to obtain business logic information.

业务处理单元,用于根据解析单元获得的业务逻辑信息进行业务处理。The business processing unit is configured to perform business processing according to the business logic information obtained by the parsing unit.

发送单元,用于将业务处理单元处理后的结果进行消息结构封装并向所述客户端发送。The sending unit is configured to encapsulate the result processed by the business processing unit in a message structure and send it to the client.

进一步,本发明实施例还提供一种终端装置,其包括:Further, an embodiment of the present invention also provides a terminal device, which includes:

分析模块,用于对JavaScript的代码文件进行词法分析和语法分析,获得远程对象名;The analysis module is used to perform lexical analysis and syntax analysis on the JavaScript code file to obtain the remote object name;

消息生成模块,用于当JavaScript对象与字符集中远程对象匹配成功后生成远程调用请求消息,该远程调用请求消息中携带所述远程对象名;A message generating module, configured to generate a remote call request message when the JavaScript object matches the remote object in the character set successfully, and the remote call request message carries the remote object name;

发送模块,用于向服务器端发送消息生成模块生成的远程调用请求消息;The sending module is used to send the remote call request message generated by the message generating module to the server;

接收模块,用于接收服务器端的处理结果,对结果进行解析后继续执行JavaScript代码。The receiving module is used to receive the processing result of the server, and continue to execute the JavaScript code after parsing the result.

本发明实施例所述的方法达到了JavaScript远程方法调用的效果,客户端与服务器端配合的方式执行JavaScript对象,可以免除从远程下载JavaScript文件的步骤,当业务逻辑复杂,或者JavaScript业务文件大时,此方法将带来明显优势,能够更好的满足用户体验上的要求。The method described in the embodiment of the present invention achieves the effect of JavaScript remote method invocation, and the client and the server cooperate to execute JavaScript objects, which can avoid the steps of downloading JavaScript files from a remote location. When the business logic is complex or the JavaScript business file is large , this method will bring obvious advantages, and can better meet the requirements of user experience.

附图说明 Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained according to these drawings on the premise of not paying creative efforts.

图1为实施例一提供的JavaScript对象处理的方法流程图。FIG. 1 is a flow chart of the JavaScript object processing method provided by the first embodiment.

图2为实施例二提供的JavaScript对象调用的方法流程图。FIG. 2 is a flow chart of the JavaScript object invocation method provided by the second embodiment.

图3为本发明实施例服务器装置结构示意图。FIG. 3 is a schematic structural diagram of a server device according to an embodiment of the present invention.

图4为本发明实施例终端装置结构示意图。FIG. 4 is a schematic structural diagram of a terminal device according to an embodiment of the present invention.

具体实施方式 detailed description

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

本发明实施例一提供的JavaScript对象处理的方法,结合图1,本发明实施例的方法流程图。The JavaScript object processing method provided by Embodiment 1 of the present invention, with reference to FIG. 1 , is a flow chart of the method in the embodiment of the present invention.

S101,接收客户端发送的远程调用请求消息。S101. Receive a remote call request message sent by a client.

在远程调用请求消息中携带有对象名、对象方法名、参数列表。参数列表中包括设备属性参数、用户信息、触发事件等,实际中可以根据需要在远程调用请求信息中携带上述一种或多种的信息。应用中可以用HTTP做承载协议,用JSON格式做包装请求消息。设备属性参数携带了其支持的显示格式。The remote call request message carries an object name, an object method name, and a parameter list. The parameter list includes device attribute parameters, user information, trigger events, etc. In practice, one or more of the above information can be carried in the remote call request information as required. In the application, HTTP can be used as the bearer protocol, and JSON format can be used as the packaging request message. The device attribute parameter carries the display format it supports.

S102,解析所述远程调用请求消息,获得业务逻辑信息。S102. Parse the remote call request message to obtain business logic information.

接收到客户端发送的远程调用请求消息后从中取出所携带的信息。根据消息中的各参数获得业务逻辑信息。After receiving the remote call request message sent by the client, the carried information is taken out. Obtain business logic information according to each parameter in the message.

S103,根据所述业务逻辑信息进行业务处理。S103. Perform service processing according to the service logic information.

接收到远程调用请求消息后,获得业务逻辑信息,相应的业务处理模块调用参数运行业务逻辑并得到处理结果。所调用的参数包含客户端发送的远程调用请求消息中携带的参数。根据远程调用请求消息中的远程对象名调用函数进行逻辑处理。如:服务器按照对象名选择不同的业务处理模块(比如一个servlet),根据对象方法名调用不同的函数,客户端发送的远程调用请求消息中的参数会是服务端参数列表中的一部分。After receiving the remote call request message, the business logic information is obtained, and the corresponding business processing module invokes parameters to run the business logic and obtains the processing result. The invoked parameters include the parameters carried in the remote invocation request message sent by the client. Call the function to perform logic processing according to the remote object name in the remote call request message. For example: the server selects different business processing modules (such as a servlet) according to the object name, calls different functions according to the object method name, and the parameters in the remote call request message sent by the client will be part of the server parameter list.

S104,将处理后的结果进行消息结构封装并向所述客户端发送。S104. Encapsulate the processed result in a message structure and send it to the client.

完成业务处理后,将处理结果按照与客户端的通讯协议封装成客户端能够处理的格式,并向客户端发送业务处理结果。After the business processing is completed, the processing results are encapsulated into a format that the client can process according to the communication protocol with the client, and the business processing results are sent to the client.

通过上述步骤实现了JavaScript对象的远程调用处理,之后客户端根据本地需要处理返回结果即可。客户端只需向服务器发送需要调用请求消息,然后接收服务端发送的处理结果。本发明实施例所述的方法达到了JavaScript远程方法调用的效果,客户端与服务器端配合的方式执行JavaScript对象,从而可以免除从远程下载JavaScript文件的步骤,当业务逻辑复杂,或者JavaScript业务文件大时,此方法将带来明显优势,能够更好的满足用户体验上的要求。Through the above steps, the remote call processing of JavaScript objects is realized, and then the client can process the returned results according to local needs. The client only needs to send a call request message to the server, and then receive the processing result sent by the server. The method described in the embodiment of the present invention achieves the effect of JavaScript remote method invocation, and the client and the server cooperate to execute JavaScript objects, thereby eliminating the step of downloading JavaScript files remotely. When the business logic is complex, or the JavaScript business files are large , this method will bring obvious advantages, and can better meet the requirements of user experience.

本发明实施例二提供的JavaScript对象调用的方法,从客户端的角度对方案进行描述,参阅图2,JavaScript对象调用的方法流程图。The method for invoking a JavaScript object provided by Embodiment 2 of the present invention describes the solution from the perspective of a client. Refer to FIG. 2 , which is a flowchart of a method for invoking a JavaScript object.

当用户在客户端创建一个JavaScript对象时,判断是否启动远程调用流程。如果需要则启动远程调用流程。When the user creates a JavaScript object on the client side, determine whether to start the remote call process. Start the remote call process if needed.

S201,客户端对JavaScript的代码文件进行词法分析和语法分析,获得远程对象名。S201. The client performs lexical analysis and syntax analysis on the JavaScript code file to obtain a remote object name.

通过词法分析获得远程对象名。然后进行语法分析,通过语法分析形成一个双向单词链表,其中语法分析过程中经字符集处理判断语法关键字和处理对象变量名。将远程对象名与字符集中的远程对象进行关键字匹配,当在字符集中的远程对象名中查找到所获得的远程对象名时则认为JavaScript对象与字符集中远程对象匹配成功。Obtain the remote object name through lexical analysis. Then perform grammatical analysis to form a two-way word linked list through grammatical analysis, wherein during the grammatical analysis process, the grammatical keywords and the variable names of the processing objects are judged through character set processing. The remote object name is matched with the remote object in the character set, and when the obtained remote object name is found in the remote object name in the character set, it is considered that the JavaScript object matches the remote object in the character set successfully.

S202,当JavaScript对象与字符集中远程对象匹配后生成远程调用请求消息。该远程调用请求消息中携带所述远程对象名。S202. Generate a remote call request message after the JavaScript object matches the remote object in the character set. The remote call request message carries the name of the remote object.

获得与待远程调用的JavaScript对象的参数,按照协议封装请求消息,可以是私有协议,例如封装成如JSON消息。消息中携带对象名、对象方法名、参数列表。参数列表中包括设备属性参数、用户信息、触发事件等。Obtain the parameters of the JavaScript object to be called remotely, and encapsulate the request message according to the protocol, which may be a private protocol, such as encapsulating it into a JSON message. The message carries the object name, object method name, and parameter list. The parameter list includes device attribute parameters, user information, trigger events, etc.

生成远程调用请求消息后按照客户端与服务器端双方约定的消息格式发送请求消息。After the remote call request message is generated, the request message is sent according to the message format agreed by both the client and the server.

S203,向服务器端发送远程调用请求消息。S203, sending a remote call request message to the server.

应用中请求消息封装成JSON消息。请求消息通过HTTP协议传输。The request message in the application is encapsulated into a JSON message. Request messages are transmitted via the HTTP protocol.

S204,接收服务器端的处理结果,所述处理结果通过处理所述远程调用请求消息获得,对结果进行解析后执行JavaScript代码。S204. Receive a processing result from the server, the processing result is obtained by processing the remote call request message, and execute JavaScript code after parsing the result.

然后显示执行的结果。Then display the result of the execution.

通过上述步骤实现了JavaScript对象的远程调用,客户端只需向服务器发送需要调用请求消息,然后接收服务端发送的处理结果。本发明实施例所述的方法达到了JavaScript远程方法调用的效果,客户端与服务器端配合的方式执行JavaScript对象,从而可以免除从远程下载JavaScript文件的步骤,当业务逻辑复杂,或者JavaScript业务文件大时,此方法将带来明显优势,能够更好的满足用户体验上的要求。Through the above steps, the remote call of the JavaScript object is realized, and the client only needs to send a call request message to the server, and then receive the processing result sent by the server. The method described in the embodiment of the present invention achieves the effect of JavaScript remote method invocation, and the client and the server cooperate to execute JavaScript objects, thereby eliminating the step of downloading JavaScript files remotely. When the business logic is complex, or the JavaScript business files are large , this method will bring obvious advantages, and can better meet the requirements of user experience.

本发明实施例三从客户端与服务器端配合的角度对方案进行描述。Embodiment 3 of the present invention describes the solution from the perspective of cooperation between the client and the server.

首先,客户端与服务器端进行协商。应用中服务器端也可以通过客户端发送的设备属性参数携带其支持的显示格式。设备属性参数可以携带于远程调用请求消息中。First, the client negotiates with the server. In the application, the server can also carry the display format it supports through the device attribute parameter sent by the client. The device attribute parameter can be carried in the remote call request message.

客户端创建一个JavaScript对象时,判断是否启动远程调用流程。当启动远程调用流程后客户端对JavaScript源程序进行词法分析,在字符集中添加远程对象名,然后进行语法分析形成一个双向单词链表,再生成中间数据结构,其中语法分析过程中根据字符集处理判断语法关键字和处理对象变量名。当对象与字符集中远程对象匹配后按照客户端与服务器端双方约定的消息格式发送远程调用请求消息。匹配的过程为关键字匹配。由JavaScript解析器负责按照协议包装消息生成远程调用请求消息。When the client creates a JavaScript object, it determines whether to start the remote call process. When the remote call process is started, the client performs lexical analysis on the JavaScript source program, adds the remote object name in the character set, and then performs grammatical analysis to form a two-way word linked list, and then generates an intermediate data structure, in which the grammatical analysis process is judged according to the character set Syntax keywords and process object variable names. When the object matches the remote object in the character set, the remote call request message is sent according to the message format agreed between the client and the server. The matching process is keyword matching. The JavaScript parser is responsible for packaging the message according to the protocol to generate the remote call request message.

请求消息可以通过HTTP协议传输。在请求消息中至少携带:对象名、对象方法名、参数列表。请求消息携带了业务逻辑的上下文信息,根据这些输入信息会产生不同的输出结果。比如客户端想要一张地图,需告诉服务器端经纬度,所需地图的尺寸等。Request messages can be transmitted via the HTTP protocol. The request message carries at least: object name, object method name, and parameter list. The request message carries the context information of the business logic, and different output results will be produced according to the input information. For example, if the client wants a map, it needs to tell the server the latitude and longitude, the size of the map, etc.

服务器端接收客户端发送的远程调用请求消息。The server receives the remote call request message sent by the client.

服务器端的监听服务端口对业务进行监听,得到消息后做消息格式审查,并按消息类型分发给相应模块做业务处理。服务器端对消息类型做日志记录。通过日志记录获得客户的行为与客户端的热点请求,可以根据日志记录进行客户行为分析。当获得远程调用请求消息后服务器端对请求的业务进行初始化,解析所述远程调用请求消息,获得业务逻辑信息,按照请求消息中携带的调用参数运行业务逻辑。完成业务逻辑运行后,服务器端对结果进行通信协议封装。The monitoring service port on the server side monitors the business, checks the message format after getting the message, and distributes it to the corresponding module for business processing according to the message type. The server side logs the message type. Obtain customer behavior and client hotspot requests through log records, and analyze customer behavior based on log records. After obtaining the remote call request message, the server side initializes the requested service, parses the remote call request message, obtains service logic information, and runs the service logic according to the call parameters carried in the request message. After completing the operation of the business logic, the server encapsulates the result with a communication protocol.

服务器端将封装好的结果发送给客户端。The server sends the encapsulated result to the client.

客户端接收到服务器端发送的结果后对结果进行解析,按照语法关键字解释执行JavaScript代码,并将显示执行的结果。After the client receives the result sent by the server, it parses the result, interprets and executes the JavaScript code according to the grammatical keywords, and displays the execution result.

本发明实施例所述的方法达到了JavaScript远程方法调用的效果,客户端与服务器端配合的方式执行JavaScript对象,可以免除从远程下载JavaScript文件的步骤,当业务逻辑复杂,或者JavaScript业务文件大时,此方法将带来明显优势,能够更好的满足用户体验上的要求。并且当通过远程调用在服务器上运行业务逻辑,客户端获得调用对象,在运行业务逻辑时,可以不仅仅是JavaScript脚本,还可以通过C、JAVA等实现,改变了如果在客户端上运行是只能运行JavaScript脚本的现状,提高了业务处理的灵活性。The method described in the embodiment of the present invention achieves the effect of JavaScript remote method invocation, and the client and the server cooperate to execute JavaScript objects, which can avoid the steps of downloading JavaScript files from a remote location. When the business logic is complex or the JavaScript business file is large , this method will bring obvious advantages, and can better meet the requirements of user experience. And when the business logic is run on the server through remote calls, the client obtains the call object. When running the business logic, it can be implemented not only by JavaScript scripts, but also by C, JAVA, etc., changing that if running on the client is only The current status of being able to run JavaScript scripts improves the flexibility of business processing.

通过上述步骤实现了JavaScript对象的远程调用处理,客户端根据本地需要处理返回结果即可。客户端只需向服务器发送需要调用请求消息,然后接收服务端发送的处理结果。本发明实施例所述的方法达到了JavaScript远程方法调用的效果,客户端与服务器端配合的方式执行JavaScript对象,从而可以免除从远程下载JavaScript文件的步骤,当业务逻辑复杂,或者JavaScript业务文件大时,此方法将带来明显优势,能够更好的满足用户体验上的要求。Through the above steps, the remote call processing of the JavaScript object is realized, and the client only needs to process the returned result according to the local needs. The client only needs to send a call request message to the server, and then receive the processing result sent by the server. The method described in the embodiment of the present invention achieves the effect of JavaScript remote method invocation, and the client and the server cooperate to execute JavaScript objects, thereby eliminating the step of downloading JavaScript files remotely. When the business logic is complex, or the JavaScript business files are large , this method will bring obvious advantages, and can better meet the requirements of user experience.

本发明实施例还提供了一种服务器,该服务器为客户端提供JavaScript对象调用处理。参阅图3,本发明实施例服务器装置结构示意图,服务器30包括:The embodiment of the present invention also provides a server, which provides JavaScript object call processing for the client. Referring to FIG. 3 , a schematic structural diagram of a server device according to an embodiment of the present invention, the server 30 includes:

接收单元301,用于接收客户端发送的远程调用请求消息。The receiving unit 301 is configured to receive a remote call request message sent by a client.

解析单元303,用于解析接收单元接收远程调用请求消息,获得业务逻辑信息。The parsing unit 303 is configured to parse the remote call request message received by the receiving unit to obtain business logic information.

业务处理单元305,用于根据解析单元获得的业务逻辑信息进行业务处理。The business processing unit 305 is configured to perform business processing according to the business logic information obtained by the parsing unit.

发送单元307,用于将业务处理单元处理后的结果进行消息结构封装并向所述客户端发送。The sending unit 307 is configured to encapsulate the result processed by the business processing unit in a message structure and send it to the client.

进一步,服务器30还包括消息监听模块311,用于根据消息头中的类型字段判断所接收的消息类型,确定接收单元301所接收的是客户端发送的远程调用请求消息。Further, the server 30 also includes a message monitoring module 311, configured to judge the type of the received message according to the type field in the message header, and determine that what the receiving unit 301 receives is a remote call request message sent by the client.

本发明实施例还提供了一种终端装置,该终端装置可以实现远程调用JavaScript对象。终端40包括:The embodiment of the present invention also provides a terminal device, which can implement remote calling of JavaScript objects. Terminal 40 includes:

分析模块401,用于对JavaScript的代码文件进行词法分析和语法分析,获得远程对象名;The analysis module 401 is used to perform lexical analysis and syntax analysis to JavaScript code files to obtain the remote object name;

消息生成模块403,用于当JavaScript对象与字符集中远程对象匹配成功后生成远程调用请求消息,该远程调用请求消息中携带所述远程对象名;The message generating module 403 is used to generate a remote call request message when the JavaScript object is successfully matched with the remote object in the character set, and the remote call request message carries the name of the remote object;

发送模块405,用于向服务器端发送消息生成模块403生成的远程调用请求消息;A sending module 405, configured to send the remote call request message generated by the message generating module 403 to the server;

接收模块407,用于接收服务器端的处理结果,对结果进行解析后继续执行JavaScript代码。The receiving module 407 is configured to receive the processing result of the server, and continue to execute the JavaScript code after parsing the result.

进一步,终端还包括一显示模块409用于将执行JavaScript的结果显示出来。Further, the terminal further includes a display module 409 for displaying the result of executing the JavaScript.

终端装置还包括一匹配模块411,用于将远程对象名与字符集中的远程对象进行关键字匹配,当在字符集中的远程对象名中查找到所获得的远程对象名时则认为JavaScript对象与字符集中远程对象匹配成功。The terminal device also includes a matching module 411, which is used to carry out keyword matching between the remote object name and the remote object in the character set. Centralized remote object matching succeeded.

本发明实施例所述的服务器端装置和客户端装置达到了JavaScript远程方法调用的效果,客户端与服务器端配合的方式执行JavaScript对象,通可以免除从远程下载JavaScript文件的步骤,当业务逻辑复杂,或者JavaScript业务文件大时,此方法将带来明显优势,能够更好的满足用户体验上的要求。并且当通过远程调用在服务器上运行业务逻辑时,可以不仅仅是JavaScript脚本,还可以通过C、JAVA等实现,改变了如果在客户端上运行是只能运行JavaScript脚本的现状,提高了业务处理的灵活性。The server-side device and the client-side device described in the embodiment of the present invention have achieved the effect of JavaScript remote method invocation, and the client-side and server-side cooperate to execute JavaScript objects, which can generally avoid the steps of downloading JavaScript files from a remote location. When the business logic is complex , or when the JavaScript business file is large, this method will bring obvious advantages, and can better meet the requirements of user experience. And when the business logic is run on the server through remote calls, it can be implemented not only by JavaScript scripts, but also by C, JAVA, etc., which changes the current situation that only JavaScript scripts can be run when running on the client, and improves business processing. flexibility.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-OnlyMemory,ROM)或随机存储记忆体(RandomAccessMemory,RAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware, and the programs can be stored in a computer-readable storage medium. During execution, it may include the processes of the embodiments of the above-mentioned methods. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM) or a random access memory (Random Access Memory, RAM) and the like.

以上所述仅为本发明的几个实施例,本领域的技术人员依据申请文件公开的可以对本发明进行各种改动或变型而不脱离本发明的精神和范围。The above descriptions are only a few embodiments of the present invention, and those skilled in the art can make various changes or modifications to the present invention according to the disclosure of the application documents without departing from the spirit and scope of the present invention.

Claims (5)

1.一种JavaScript对象调用的方法,其特征在于,所述方法包括:1. A method for JavaScript object calling, characterized in that the method comprises: 对JavaScript的代码文件进行词法分析和语法分析,获得远程对象名;Perform lexical analysis and syntax analysis on the JavaScript code file to obtain the remote object name; 当JavaScript对象与字符集中远程对象匹配成功后生成远程调用请求消息,该远程调用请求消息中携带所述远程对象名、所述远程对象方法名、参数列表,所述参数列表包括设备属性参数、用户信息、触发事件;When the JavaScript object is successfully matched with the remote object in the character set, a remote call request message is generated. The remote call request message carries the name of the remote object, the name of the method of the remote object, and a list of parameters, and the list of parameters includes device attribute parameters, user information, trigger events; 向服务器端发送所述远程调用请求消息;Send the remote call request message to the server; 接收服务器端的处理结果,所述处理结果通过处理所述远程调用请求消息获得,对结果进行解析后继续执行JavaScript代码;Receiving the processing result of the server end, the processing result is obtained by processing the remote call request message, and continuing to execute the JavaScript code after parsing the result; 其中,所述处理结果通过处理所述远程调用请求消息获得具体为,所述处理结果由所述远程对象名选择不同的业务处理模块,并在所述不同的业务处理模块中根据所述远程对象方法名调用不同的函数进行逻辑处理获得。Wherein, the processing result is obtained by processing the remote call request message, specifically, the processing result is selected from a different business processing module by the name of the remote object, and in the different business processing modules, according to the remote object The method name is obtained by calling different functions for logical processing. 2.如权利要求1所述的方法,其特征在于,通过语法分析形成一个双向单词链表,其中语法分析过程中经字符集处理判断语法关键字和处理对象变量名。2. The method according to claim 1, wherein a two-way linked list of words is formed through grammatical analysis, wherein the grammatical keyword and the variable name of the processing object are judged through character set processing in the grammatical analysis process. 3.如权利要求1所述的方法,其特征在于,所述方法还包括:将远程对象名与字符集中的远程对象进行关键字匹配,当在字符集中的远程对象名中查找到所获得的远程对象名时则认为JavaScript对象与字符集中远程对象匹配成功。3. The method according to claim 1, further comprising: carrying out keyword matching between the remote object name and the remote object in the character set, when the obtained remote object name is found in the character set When the remote object name is used, it is considered that the JavaScript object matches the remote object in the character set successfully. 4.一种终端装置,其特征在于,所述终端装置包括:4. A terminal device, characterized in that the terminal device comprises: 分析模块,用于对JavaScript的代码文件进行词法分析和语法分析,获得远程对象名;The analysis module is used to perform lexical analysis and syntax analysis on the JavaScript code file to obtain the remote object name; 消息生成模块,用于当JavaScript对象与字符集中远程对象匹配成功后生成远程调用请求消息,该远程调用请求消息中携带所述远程对象名、所述远程对象方法名、参数列表,所述参数列表包括设备属性参数、用户信息、触发事件;发送模块,用于向服务器端发送消息生成模块生成的远程调用请求消息;A message generation module, used to generate a remote call request message when the JavaScript object is successfully matched with the remote object in the character set, the remote call request message carries the name of the remote object, the method name of the remote object, a parameter list, and the parameter list Including device attribute parameters, user information, and trigger events; a sending module, used to send the remote call request message generated by the message generation module to the server; 接收模块,用于接收服务器端的处理结果,对结果进行解析后继续执行JavaScript代码;其中,所述处理结果由所述远程对象名选择不同的业务处理模块,并在所述不同的业务处理模块中根据所述远程对象方法名调用不同的函数进行逻辑处理获得。The receiving module is used to receive the processing result of the server, and continue to execute the JavaScript code after parsing the result; wherein, the processing result selects a different business processing module according to the remote object name, and in the different business processing module According to the method name of the remote object, different functions are called to perform logical processing. 5.如权利要求4所述的终端装置,其特征在于,所述终端装置还包括:5. The terminal device according to claim 4, further comprising: 匹配模块,用于将远程对象名与字符集中的远程对象进行关键字匹配,当在字符集中的远程对象名中查找到所获得的远程对象名时则认为JavaScript对象与字符集中远程对象匹配成功。The matching module is used to perform keyword matching between the remote object name and the remote object in the character set. When the obtained remote object name is found in the remote object names in the character set, it is considered that the JavaScript object matches the remote object in the character set successfully.
CN200910106428.3A 2009-03-31 2009-03-31 The method called and process of JavaScript object, device Active CN101854371B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910106428.3A CN101854371B (en) 2009-03-31 2009-03-31 The method called and process of JavaScript object, device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910106428.3A CN101854371B (en) 2009-03-31 2009-03-31 The method called and process of JavaScript object, device

Publications (2)

Publication Number Publication Date
CN101854371A CN101854371A (en) 2010-10-06
CN101854371B true CN101854371B (en) 2016-08-03

Family

ID=42805636

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910106428.3A Active CN101854371B (en) 2009-03-31 2009-03-31 The method called and process of JavaScript object, device

Country Status (1)

Country Link
CN (1) CN101854371B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2597568A4 (en) * 2010-12-16 2013-07-17 Huawei Tech Co Ltd Method and device for improving performance of mobile widget
CN102141914A (en) * 2010-12-16 2011-08-03 华为技术有限公司 Method and device for enhancing performance of mobile Widget application
CN102158482B (en) * 2011-03-10 2013-11-20 易程(苏州)软件股份有限公司 JSON (JavaScript Object Notation) data protocol based passenger transport information communication method and system
US20130091197A1 (en) 2011-10-11 2013-04-11 Microsoft Corporation Mobile device as a local server
IN2014CN02434A (en) * 2011-10-11 2015-06-19 Microsoft Corp
CN103095785B (en) * 2011-11-08 2016-04-06 阿里巴巴集团控股有限公司 Remote procedure calling (PRC) method and system, client and server
CN102810069A (en) * 2012-07-16 2012-12-05 深圳市融创天下科技股份有限公司 JAVA object requesting and responding methods, devices and systems and terminal
US9600351B2 (en) 2012-12-14 2017-03-21 Microsoft Technology Licensing, Llc Inversion-of-control component service models for virtual environments
CN103051728B (en) * 2013-01-10 2015-07-08 太仓市同维电子有限公司 Remote-procedure calling method
CN103338190B (en) * 2013-06-13 2016-05-11 国家电网公司 Based on the believable unstructured data secure exchange of user behavior method
CN103473116B (en) * 2013-09-11 2016-09-14 北京思特奇信息技术股份有限公司 A kind of Volume data remote invocation method and device
US9853956B2 (en) * 2014-02-11 2017-12-26 Texas Instruments Incorporated JSON encryption and hashing with indication added to key-value
CN105718294A (en) * 2015-03-23 2016-06-29 上海赞越软件服务中心 Permission interconnected contact person dialogue through jQuery mechanism numbers
CN105072703B (en) * 2015-07-20 2018-11-27 上海摩软通讯技术有限公司 The data transmission of Wifi-Direct network and processing method and system
CN110309931B (en) * 2018-03-20 2023-06-23 腾讯科技(深圳)有限公司 Service optimization method and device
CN109815718A (en) * 2019-01-18 2019-05-28 国能日新科技股份有限公司 WAR program source file encryption protecting method and system
CN111600861A (en) * 2020-05-08 2020-08-28 格尔软件股份有限公司 Method for issuing digital certificate compatible with multiple terminals and multiple browsers

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1577277A (en) * 2003-07-16 2005-02-09 惠普开发有限公司 Managing program applications
CN1620060A (en) * 2003-11-17 2005-05-25 国际商业机器公司 Integrating browser-incompatible information into web content and method for displaying the information
CN101207624A (en) * 2006-12-19 2008-06-25 国际商业机器公司 Method and system for configuring an application component in a network

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1577277A (en) * 2003-07-16 2005-02-09 惠普开发有限公司 Managing program applications
CN1620060A (en) * 2003-11-17 2005-05-25 国际商业机器公司 Integrating browser-incompatible information into web content and method for displaying the information
CN101207624A (en) * 2006-12-19 2008-06-25 国际商业机器公司 Method and system for configuring an application component in a network

Also Published As

Publication number Publication date
CN101854371A (en) 2010-10-06

Similar Documents

Publication Publication Date Title
CN101854371B (en) The method called and process of JavaScript object, device
TWI654860B (en) Hybrid application client resource calling method, client and system
US6952800B1 (en) Arrangement for controlling and logging voice enabled web applications using extensible markup language documents
US7920852B2 (en) Compression of data transmitted between server and mobile device
CN113010827B (en) Page rendering method, device, electronic device and storage medium
CN112328342B (en) To-do item processing method and device based on online document
CN107766509B (en) Method and device for static backup of webpage
CN104301443A (en) Method and system for calling end capacity ports on web page
CN112882709B (en) Rendering method, device, equipment and storage medium based on container engine system
CN110224896B (en) Network performance data acquisition method and device and storage medium
CN104967542A (en) Mobile end page testing method, device and system
WO2012094945A1 (en) Microblog message processing method and device thereof
CN109067860B (en) Mobile terminal message processing method and related device
CN110417919A (en) Method and device for traffic hijacking
CN104572099A (en) Assembly and middleware based low-coupling frame data processing method and system
CN106933623B (en) Operation method, device and system of installation-free application
CN115982257A (en) Interface creation method and related device
CN115600023A (en) Client page skipping method, device and equipment and storage medium
CN101964742B (en) Method, system and device for using network open ability
US9323722B1 (en) Low-latency interactive user interface
CN118643485B (en) Verification code display method, device, equipment, storage medium and product
US20060075069A1 (en) Method and system to provide message communication between different application clients running on a desktop
CN112015383A (en) A login method and device
CN114385382A (en) Access method, device, computer device and storage medium for light application
CN113055348B (en) Cross-platform data request method and device and electronic equipment

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
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20201123

Address after: Unit 2414-2416, main building, no.371, Wushan Road, Tianhe District, Guangzhou City, Guangdong Province

Patentee after: GUANGDONG GAOHANG INTELLECTUAL PROPERTY OPERATION Co.,Ltd.

Address before: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen

Patentee before: HUAWEI TECHNOLOGIES Co.,Ltd.

Effective date of registration: 20201123

Address after: 215500 No.13, Caotang Road, Changshu, Suzhou, Jiangsu Province

Patentee after: Changshu intellectual property operation center Co.,Ltd.

Address before: Unit 2414-2416, main building, no.371, Wushan Road, Tianhe District, Guangzhou City, Guangdong Province

Patentee before: GUANGDONG GAOHANG INTELLECTUAL PROPERTY OPERATION Co.,Ltd.

CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: 215500 5th floor, building 4, 68 Lianfeng Road, Changfu street, Changshu City, Suzhou City, Jiangsu Province

Patentee after: Changshu intellectual property operation center Co.,Ltd.

Address before: No.13 caodang Road, Changshu City, Suzhou City, Jiangsu Province

Patentee before: Changshu intellectual property operation center Co.,Ltd.