CN107479982B - data synchronization method and terminal - Google Patents

data synchronization method and terminal Download PDF

Info

Publication number
CN107479982B
CN107479982B CN201710531155.1A CN201710531155A CN107479982B CN 107479982 B CN107479982 B CN 107479982B CN 201710531155 A CN201710531155 A CN 201710531155A CN 107479982 B CN107479982 B CN 107479982B
Authority
CN
China
Prior art keywords
attribute
value
user interface
binding information
property
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
CN201710531155.1A
Other languages
Chinese (zh)
Other versions
CN107479982A (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.)
Fujian Netdragon Websoft Co Ltd
Original Assignee
Fujian Netdragon Websoft 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 Fujian Netdragon Websoft Co Ltd filed Critical Fujian Netdragon Websoft Co Ltd
Priority to CN201710531155.1A priority Critical patent/CN107479982B/en
Publication of CN107479982A publication Critical patent/CN107479982A/en
Application granted granted Critical
Publication of CN107479982B publication Critical patent/CN107479982B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the field of coding, in particular to a method and a terminal for data synchronization.A source object is preset through S1, S2, a user interface component corresponding to the source object is obtained, S3, a th attribute of the source object and a second attribute of the user interface component are bound, and S4, when the value of the th attribute changes, the value of the second attribute is updated according to the current value of the th attribute.

Description

data synchronization method and terminal
Technical Field
The present invention relates to the field of coding, and in particular, to a method and a terminal for data synchronization.
Background
When business data changes, events are dispatched, and the user interface component in the business presentation layer listens to the events and presents the content of the event to the user interface if the event is required by the user interface component.
For example, in a game, when a player is hacked, events named as "hacking" are dispatched, wherein the content of the event is the player id and the value of the current attribute (blood volume, magic, physical strength … …) of the player, at this time, the user interface components of all players in the same scenario receive the event, then according to the player id, whether the event is related to the event or not is judged (the player id in the event is equal to the player id corresponding to the user interface component), and if so, other attributes of the event are taken out and updated to the user interface.
However, if there are thousand players in the current scenario, thousand players respond to the chopping event at the same time, but only players really concern the event, therefore, the existing event distribution mechanism is used to synchronize the service data generated by the service logic layer and the data displayed by the user interface components in the service presentation layer, the utilization rate of system resources is low, the system load is large, and the system performance is reduced, and the user experience is influenced.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: how to improve the utilization rate of system resources in the process of synchronizing the service data generated by the service logic layer and the data displayed by the service presentation layer.
In order to solve the technical problems, the invention adopts the technical scheme that:
the invention provides data synchronization methods, which comprise:
s1, presetting a source object;
s2, acquiring user interface components corresponding to the source objects;
s3, binding the th property of the source object and the second property of the user interface component;
s4, when the value of the attribute changes, updating the value of the second attribute according to the current value of the attribute.
The present invention also provides data synchronized terminals, comprising or more processors and memory, the memory storing programs and configured to be executed by the or more processors to perform the steps of:
s1, presetting a source object;
s2, acquiring user interface components corresponding to the source objects;
s3, binding the th property of the source object and the second property of the user interface component;
s4, when the value of the attribute changes, updating the value of the second attribute according to the current value of the attribute.
The method has the advantages that the attribute value of the user interface component bound with the source object is changed along with the attribute value of the source object by directly binding the attribute of the source object and the attribute of the user interface component corresponding to the source object, and the user interface components of other objects except the source object do not respond in scenes, so that the utilization rate of system resources is improved in the process of synchronizing the service data generated by the service logic layer and the data displayed by the service presentation layer, the system load is reduced, and the system performance and the user experience are improved.
Drawings
FIG. 1 is a flow chart diagram of an embodiment of a method for synchronizing kinds of data according to the present invention;
fig. 2 is a block diagram of a specific embodiment of data synchronization terminals provided in the present invention;
description of reference numerals:
1. a processor; 2. a memory.
Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
Referring to fig. 1 to fig. 2,
as shown in fig. 1, the present invention provides methods for data synchronization, comprising:
s1, presetting a source object;
s2, acquiring user interface components corresponding to the source objects;
s3, binding the th property of the source object and the second property of the user interface component;
s4, when the value of the attribute changes, updating the value of the second attribute according to the current value of the attribute.
, the step S3 is followed by:
generating binding information including an only identifier for the source object, a name of the th property, a only identifier for the user interface component, and a name of the second property;
and storing the binding information to a preset binding information list.
, the step S4 specifically includes:
when the value of the th attribute changes,
and judging whether a second attribute bound with the th attribute exists in the binding information list, and if so, updating the value of the second attribute according to the current value of the th attribute.
, further comprising:
deleting the binding information from the binding information list.
, further comprising:
unbinding the th attribute and the second attribute.
As shown in fig. 2, the present invention further provides data synchronization terminals, including or more processors 1 and a memory 2, where the memory 2 stores programs and is configured to be executed by the or more processors 1 to perform the following steps:
s1, presetting a source object;
s2, acquiring user interface components corresponding to the source objects;
s3, binding the th property of the source object and the second property of the user interface component;
s4, when the value of the attribute changes, updating the value of the second attribute according to the current value of the attribute.
, the step S3 is followed by:
generating binding information including an only identifier for the source object, a name of the th property, a only identifier for the user interface component, and a name of the second property;
and storing the binding information to a preset binding information list.
, the step S4 specifically includes:
when the value of the th attribute changes,
and judging whether a second attribute bound with the th attribute exists in the binding information list, and if so, updating the value of the second attribute according to the current value of the th attribute.
, further comprising:
deleting the binding information from the binding information list.
, further comprising:
unbinding the th attribute and the second attribute.
Example of the present invention is:
the present embodiment provides methods for data synchronization, including:
s1, presetting a source object;
for example, in a game, Player object Player is preset as a source object;
s2, acquiring user interface components corresponding to the source objects;
for example, user interface component hpLabel corresponding to the Player object Player is obtained, the user interface component hpLabel being used to display the current blood volume of the Player object Player;
s3, binding the th property of the source object and the second property of the user interface component;
for example, the blood volume value property hp of the source object and the property text of the user component hpLabel are bound, wherein the value of the player blood volume value displayed on the user interface is the same as the value of the property text of the hpLabel;
s4, generating binding information, wherein the binding information comprises a unique identifier of the source object, a name of the th attribute, a unique identifier of the user interface component and a name of the second attribute;
for example, the binding information is { Player, hp, hpLabel, text }, and sequentially represents the source object, the th property value of the source object, the user interface component, and the second property value of the user interface component;
s5, storing the binding information to a preset binding information list;
s6, when the value of the attribute changes, updating the value of the second attribute according to the current value of the attribute, specifically:
when the value of the th attribute changes,
judging whether a second attribute bound with the th attribute exists in the binding information list, and if so, updating the value of the second attribute according to the current value of the th attribute;
when the value of the hp attribute changes, the Player object Player sends a notification message of the change of the blood volume value of a Player, and after the system receives the notification message, the system automatically searches the binding information list to check whether a user interface component bound with the hp attribute of the Player object Player exists or not, so as to find the user interface component associated with the user interface component, and all the user interface components of all the Player objects in the current game scene do not need to execute the operation of judging whether the user interface components are associated objects of the Player object Player or not, so that the utilization rate of system resources is improved in the process of synchronizing the service data generated by the service logic layer and the data displayed by the service presentation layer;
for example, if the player object player is hacked by monster, the value of the blood volume is decreased, the value of the hp attribute is changed from 100 to 80, at this time, the value of the text attribute of the hpLabel is updated to 80, and the value of the blood volume of the player object player displayed on the user interface is 80;
s7, unbinding the th attribute and the second attribute, specifically:
deleting the binding information from the binding information list;
the binding relationship of the attributes among different objects can be flexibly set, and later maintenance is facilitated.
As can be seen from the above description, the data synchronization method provided in this embodiment directly binds the hp attribute of the Player object Player and the text attribute of the hpLabel of the user interface component of the Player object, so that when the value of the hp attribute of the Player object Player changes, the value of the text attribute of the hpLabel changes accordingly, and thus the blood volume value of the Player displayed on the user interface changes. Compared with the existing event dispatch mechanism, the data synchronization method provided by the embodiment has the following advantages:
, in the process of synchronizing the hp attribute value and the text attribute value, the user interface components of other objects in the scene do not respond, compared with the existing event distribution mechanism, the system resource utilization rate is improved in the process of synchronizing the service data generated by the service logic layer and the data displayed by the service presentation layer, the system load is reduced, and therefore the system performance and the user experience are improved;
secondly, a data synchronization method realized based on an event distribution mechanism has the defects that as the complexity of a system is improved and the functions are increased, the events in the system are various and are difficult to maintain in the later period; the data synchronization method provided by the embodiment maintains the binding relationship of the attributes between different objects through the binding information list, the source code is not required to be modified, the binding relationship between the objects can be easily maintained only by modifying the binding information list, and the convenience of later maintenance is improved;
thirdly, an event model in the data synchronization method realized based on the event dispatch mechanism is only responsible for dispatching and monitoring events, and a specific realization code of a synchronization attribute value needs to be repeatedly written in different user interface components, for example, a text attribute of an hpLabel (hpLabel) of a user interface component is updated according to a value of an hp attribute of a Player object Player, a text attribute of a levelLabel of the user interface component is updated according to a value of a level attribute of the Player object Player, service logics of two data synchronization operations are the same and are both assigned operations, and two synchronization statements with the same service logics and different parameters need to be written when the code is written by using the data synchronization method realized based on the event dispatch mechanism;
and fourthly, a plurality of different events such as chopping events, upgrading events, medicine drinking events and the like can trigger the hp attribute value of the Player object to change, when a data synchronization method realized based on an event distribution mechanism is adopted, if an event distribution mechanism is not set in a certain logic which can cause the hp attribute value to change, the blood volume value data displayed on a user interface and the service data are not synchronous, and the data synchronization method provided by the invention directly binds two attributes, namely automatically synchronizes to the specified attributes of another objects when the attribute values of objects change, thereby avoiding the generation of 'missing' distribution events from the source and improving the accuracy of data synchronization.
The second embodiment of the invention is as follows:
the present embodiment provides data synchronization terminals, including or more processors 1 and a memory 2, where the memory 2 stores programs and is configured to be executed by the or more processors 1 to perform the following steps:
s1, presetting a source object;
s2, acquiring user interface components corresponding to the source objects;
s3, binding the th property of the source object and the second property of the user interface component;
s4, generating binding information, wherein the binding information comprises a unique identifier of the source object, a name of the th attribute, a unique identifier of the user interface component and a name of the second attribute;
s5, storing the binding information to a preset binding information list;
s6, when the value of the attribute changes, updating the value of the second attribute according to the current value of the attribute, specifically:
when the value of the th attribute changes,
judging whether a second attribute bound with the th attribute exists in the binding information list, and if so, updating the value of the second attribute according to the current value of the th attribute;
s7, unbinding the th attribute and the second attribute, specifically:
deleting the binding information from the binding information list.
In summary, the data synchronization method and terminal provided by the present invention enable the attribute value of the user interface component bound with the source object to change with the attribute value of the source object by directly binding the attribute of the user interface component corresponding to the source object, and the user interface components of other objects except the source object in the same scenario do not make a response action, thereby achieving an improvement in the utilization rate of system resources during the process of synchronizing data generated by the service logic layer and data displayed by the service presentation layer, and reducing the system load, thereby improving the system performance and user experience, , the data synchronization method implemented based on the event dispatch mechanism, increases the system complexity and functions, and makes the system more numerous events, which are difficult to maintain later, and the data synchronization method provided by the present embodiment maintains the binding relationship between different objects through the binding information list, does not need to modify the source code, and can easily maintain the binding relationship between the objects, thereby improving the convenience of maintenance, , the Player synchronization method implemented based on the event dispatch information list, only needs to modify the Player data synchronization attribute value, and the Player synchronization code update is written according to the event synchronization parameter when the synchronization parameter of the Player synchronization information synchronization process of the Player synchronization module, the synchronization module, which is written according to the synchronization process that the synchronization of the event synchronization module, the event synchronization module is written according to the event synchronization of which is written, the event synchronization module which is written when the event synchronization module is written, the synchronization module which is written, the synchronization of the synchronization module which is written, the synchronization module is written according to the synchronization of the synchronization module, the synchronization module which is written when the synchronization module which is written, the synchronization module, the synchronization of the synchronization module which is written, the synchronization module which is written, the synchronization module of the synchronization module which is written according to which is written when the synchronization of the synchronization module, the synchronization module of the.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

Claims (8)

1, A method for data synchronization, comprising:
s1, presetting a source object;
s2, acquiring user interface components corresponding to the source objects;
s3, binding the th property of the source object and the second property of the user interface component;
s4, when the value of the attribute changes, updating the value of the second attribute according to the current value of the attribute;
the S3 further includes:
generating binding information including an only identifier for the source object, a name of the th property, a only identifier for the user interface component, and a name of the second property;
and storing the binding information to a preset binding information list.
2. The data synchronization method according to claim 1, wherein the S4 specifically is:
when the value of the th attribute changes,
and judging whether a second attribute bound with the th attribute exists in the binding information list, and if so, updating the value of the second attribute according to the current value of the th attribute.
3. The method of data synchronization of claim 1, further comprising:
deleting the binding information from the binding information list.
4. The method of data synchronization of claim 1, further comprising:
unbinding the th attribute and the second attribute.
A terminal for data synchronization of , comprising one or more processors and a memory, the memory storing a program and configured to be executed by the one or more processors to perform the steps of:
s1, presetting a source object;
s2, acquiring user interface components corresponding to the source objects;
s3, binding the th property of the source object and the second property of the user interface component;
s4, when the value of the attribute changes, updating the value of the second attribute according to the current value of the attribute;
the S3 further includes:
generating binding information including an only identifier for the source object, a name of the th property, a only identifier for the user interface component, and a name of the second property;
and storing the binding information to a preset binding information list.
6. The terminal for data synchronization according to claim 5, wherein the S4 is specifically:
when the value of the th attribute changes,
and judging whether a second attribute bound with the th attribute exists in the binding information list, and if so, updating the value of the second attribute according to the current value of the th attribute.
7. The terminal for data synchronization according to claim 5, further comprising:
deleting the binding information from the binding information list.
8. The terminal for data synchronization according to claim 5, further comprising:
unbinding the th attribute and the second attribute.
CN201710531155.1A 2017-07-03 2017-07-03 data synchronization method and terminal Active CN107479982B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710531155.1A CN107479982B (en) 2017-07-03 2017-07-03 data synchronization method and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710531155.1A CN107479982B (en) 2017-07-03 2017-07-03 data synchronization method and terminal

Publications (2)

Publication Number Publication Date
CN107479982A CN107479982A (en) 2017-12-15
CN107479982B true CN107479982B (en) 2020-01-31

Family

ID=60595289

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710531155.1A Active CN107479982B (en) 2017-07-03 2017-07-03 data synchronization method and terminal

Country Status (1)

Country Link
CN (1) CN107479982B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110727799B (en) * 2018-06-29 2022-08-16 杭州海康威视数字技术股份有限公司 Ontology construction method and device
CN116319094B (en) * 2023-05-19 2023-08-11 北京安帝科技有限公司 Data safety transmission method, computer equipment and medium based on tobacco industry

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1555612A2 (en) * 2004-01-02 2005-07-20 Microsoft Corporation System and method for implicit synchronization of message-queue-based user interface with an automatic code
CN1684034A (en) * 2004-04-13 2005-10-19 微软公司 Application of data-binding mechanism to perform command binding
CN1922609A (en) * 2004-02-19 2007-02-28 高通剑桥有限公司 Rendering a user interface
CN100371900C (en) * 2006-01-19 2008-02-27 华为技术有限公司 Method and system for synchronizing data
CN103597464A (en) * 2011-06-13 2014-02-19 微软公司 Techniques for adapting an interpretive runtime application to multiple clients

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1555612A2 (en) * 2004-01-02 2005-07-20 Microsoft Corporation System and method for implicit synchronization of message-queue-based user interface with an automatic code
CN1922609A (en) * 2004-02-19 2007-02-28 高通剑桥有限公司 Rendering a user interface
CN1684034A (en) * 2004-04-13 2005-10-19 微软公司 Application of data-binding mechanism to perform command binding
CN100371900C (en) * 2006-01-19 2008-02-27 华为技术有限公司 Method and system for synchronizing data
CN103597464A (en) * 2011-06-13 2014-02-19 微软公司 Techniques for adapting an interpretive runtime application to multiple clients

Also Published As

Publication number Publication date
CN107479982A (en) 2017-12-15

Similar Documents

Publication Publication Date Title
CN108536761B (en) Report data query method and server
CN110493067B (en) Method and device for updating API gateway service
CN108536538A (en) Processor core dispatching method, device, terminal and storage medium
US8635253B2 (en) Decorated model architecture for efficient model-driven application development
CN106790549B (en) Data updating method and device
CN109919691B (en) Data processing system, method and device
CN108509248B (en) Data processing method and device, storage medium, processor and terminal
CN111694857B (en) Method, device, electronic equipment and computer readable medium for storing resource data
CN110138652B (en) Session updating method and device and client device
EP3059674A1 (en) Service processing method and apparatus based on bpm
CN109840115A (en) RecyclerView paging loading method and device in a kind of android system
CN102999608A (en) System and method for tree table demonstration of large data
CN108664521B (en) Method and device for providing serial number, electronic equipment and readable storage medium
CN113181646A (en) Game data method and device, electronic equipment and storage medium
CN107479982B (en) data synchronization method and terminal
CN107133160B (en) Server and client
CN113452617A (en) Dynamic gateway route management method, device and storage medium
CN111064626A (en) Configuration updating method, device, server and readable storage medium
CN111736950A (en) Accelerator resource adding method of virtual machine and related device
WO2016147073A1 (en) Method and apparatus for identifying changed mailboxes in an internet message access protocol (imap) list
CN110673827B (en) Resource calling method and device based on android system and electronic equipment
CN113254217A (en) Service message processing method and device and electronic equipment
CN110324722B (en) Method, device, equipment and storage medium for acquiring data in live broadcast room
CN117156191A (en) Interface display method, device, electronic equipment and computer readable storage medium
CN108762753A (en) Page assembly amending method and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant