Synchronization method, apparatus and device for login state, and storage medium

CN114721836BActive Publication Date: 2026-08-07WUHAN DOUYU NETWORK TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
WUHAN DOUYU NETWORK TECHNOLOGY CO LTD
Filing Date
2021-01-05
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

而随着功能模块数量的增加,获取登录状态会变得非常复杂,并且若在获取登录状态的过程又出现页面登录状态的变化,也不能及时有效的将登录状态同步至这些功能模块中,因此,如何高效的同步页面登录状态显得尤为重要

Benefits of technology

[0016]第四方面,本发明实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理装置执行时实现如本发明实施例所述的登录状态的同步方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114721836B_ABST
    Figure CN114721836B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a login state synchronization method, device and equipment and a storage medium. The method comprises the following steps: defining a synchronization class function; the synchronization class function inherits a system base class function; calling an initialization function in the synchronization class function, judging whether the synchronization class function is registered in an event bus or not; if the synchronization class function is registered in the event bus, calling a listening function to listen to a login state of a page; when the login state information is listened to, calling a broadcast function to broadcast the login state information, so as to synchronize the login state information. The login state synchronization method provided by the embodiments of the present application can synchronize the login state information out through the broadcasting mode when the login state of the page is listened to, can synchronize the login state in time, and reduces the complexity of the login state synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, apparatus, device and storage medium for synchronizing login status. Background Technology

[0002] Currently, this is achieved by calling multiple functional modules when loading a web page. When the login status on the page changes, some functional modules need to obtain the updated login status to synchronize the login status.

[0003] In related technologies, some functional modules need to dynamically obtain the login status when the page changes. However, as the number of functional modules increases, obtaining the login status becomes very complex. Furthermore, if the page login status changes during the process of obtaining the login status, it is not possible to synchronize the login status to these functional modules in a timely and effective manner. Therefore, how to efficiently synchronize the page login status is particularly important. Summary of the Invention

[0004] This invention provides a method, apparatus, device, and storage medium for synchronizing login status, which can synchronize login status in a timely manner and reduce the complexity of login status synchronization.

[0005] In a first aspect, embodiments of the present invention provide a method for synchronizing login status, comprising:

[0006] Define a synchronization class function; the synchronization class function inherits from the system base class function;

[0007] Call the initialization function in the synchronization class function to determine whether the synchronization class function is registered to the event bus;

[0008] If the synchronization function is registered in the event bus, the listener function is called to listen for the login status of the page;

[0009] When login status information is detected, a broadcast function is called to broadcast the login status information in order to synchronize the login status information.

[0010] Secondly, embodiments of the present invention also provide a login status synchronization device, comprising:

[0011] The synchronization class function definition module is used to define synchronization class functions; these synchronization class functions inherit from the system base class functions.

[0012] The registration judgment module is used to call the initialization function in the synchronization class function to determine whether the synchronization function is registered to the event bus;

[0013] The login status monitoring module is used to call the monitoring function to monitor the login status of the page when the synchronous class function is registered to the event bus;

[0014] The login status information broadcasting module is used to broadcast the login status information by calling a broadcast function when the login status information is detected, so as to synchronize the login status information.

[0015] Thirdly, embodiments of the present invention also provide a computer device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the login status synchronization method as described in the embodiments of the present invention.

[0016] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processing device, implements the login status synchronization method as described in the embodiments of the present invention.

[0017] This invention discloses a method, apparatus, device, and storage medium for synchronizing login status. A synchronization class function is defined; this function inherits from a system base class function; an initialization function within the synchronization class function is called to determine if the synchronization class function is registered in the event bus; if registered, a listening function is called to monitor the page's login status; when login status information is detected, a broadcast function is called to broadcast the login status information to synchronize it. The login status synchronization method provided by this invention synchronizes login status information promptly by broadcasting it when the page's login status is detected, reducing the complexity of login status synchronization. Attached Figure Description

[0018] Figure 1 This is a flowchart of a login status synchronization method according to Embodiment 1 of the present invention;

[0019] Figure 2 This is a schematic diagram of the structure of a login status synchronization device according to Embodiment 2 of the present invention;

[0020] Figure 3 This is a schematic diagram of the structure of a computer device according to Embodiment 3 of the present invention. Detailed Implementation

[0021] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0022] Example 1

[0023] Figure 1 This is a flowchart of a login status synchronization method provided in Embodiment 1 of the present invention. This embodiment is applicable to situations where the login status of a page is synchronized. The method can be executed by a login status synchronization device, which can consist of hardware and / or software and is generally integrated into a device with login status synchronization functionality. This device can be an electronic device such as a server or server cluster. Figure 1 As shown, the method specifically includes the following steps:

[0024] Step 110: Define the synchronization class function.

[0025] In this implementation, the synchronized class function inherits from the system base class function. The synchronized class function can be defined as the `DYLoginProxy` class, and the system base class function can be defined as `MZBaseManager`. In this embodiment, the `DYLoginProxy` class inherits from the `MZBaseManager` class, which is a base class containing many system callback methods that can be used via callbacks. The specific class definition is as follows: `class DYLoginProxy(var mContext:Context):MZBaseManager(mContext){}`. Here, `DYLoginProxy` represents the synchronized class function, `MZBaseManager` represents the system base class, and `mContext` represents a method in the system base class. This definition indicates that the synchronized class function inherits from the system base class, and the methods in the system base class can be used via callbacks by the synchronized class function. Inheriting the synchronized class function from the system base class eliminates the need to repeatedly define methods from the system base class within the synchronized class function, allowing direct calls to methods from the system base class, thus simplifying the writing process of the synchronized class function.

[0026] Step 120: Call the initialization function in the synchronization class function to determine whether the synchronization class function is registered in the event bus.

[0027] The initialization function can be implemented through the init code block, which can be defined as: init{}.

[0028] In this embodiment, the method to determine whether a synchronization class function is registered to the event bus by calling the initialization function in the synchronization class function can be as follows: obtain the set constructor in the initialization function; determine whether the object passed in the set constructor is the event bus; if so, then the synchronization class function is registered to the event bus.

[0029] Specifically, the logic within the `init` block is used to determine whether a synchronized class function is registered with the event bus. The specific logic is as follows: `if(!DYEvent.getDefault().isRegistered(this))`.

[0030] First, a default constructor is obtained using DYEvent.getDefault(). Then, isRegistered(this) is called in the constructor. This function takes the 'this' object as input, which is the DYLoginProxy object itself, to determine whether DYLoginProxy has been registered with the DYEvent bus. If it has not been registered, it is registered; otherwise, it is not registered.

[0031] Here, DYEvent represents the event bus, which can be understood as a channel for synchronizing the page login status to the synchronization class function DYLoginProxy. getDefault() is the constructor retrieval function, and isRegistered(this) indicates a registered constructor. That is, by calling getDefault(), you can obtain the registered constructor isRegistered(this). this refers to the object passed to the constructor, which in this case refers to the synchronization class function DYLoginProxy.

[0032] The `if(!DYEvent.getDefault().isRegistered(this))` statement indicates whether the synchronization function `DYLoginProxy` is registered with the `DYEvent` event bus. In this embodiment, only when the synchronization function is registered with the event bus can the `DYLoginProxy` function obtain the page login status through the `DYEvent` bus and then synchronize the page login status through the logic in the `DYLoginProxy` function. Therefore, registering the synchronization function with the event bus is a prerequisite for login status synchronization.

[0033] In this embodiment, the initialization function `init` block in the synchronous class function `DYLoginProxy` is executed. A default registration constructor is obtained by calling `DYEvent.getDefault()`. Then, `isRegistered(this)` in the constructor is called to determine whether the `this` object in the function points to `DYLoginProxy`. If it does, it means that `DYLoginProxy` has been registered to the `DYEvent` bus; otherwise, `DYLoginProxy` has not been registered to the `DYEvent` bus.

[0034] Specifically, after determining whether a synchronized function is registered to the event bus, the following steps are also included: if the synchronized function is not registered to the event bus, the setter in the initialization function is obtained; the object passed in the setter is set as the event bus to register the synchronized function to the event bus.

[0035] In this embodiment, the logic for registering the synchronous class function to the event bus is as follows: DYEvent.getDefault().Register(this).

[0036] First, the default registration constructor is obtained by calling DYEvent.getDefault(), and then the `Register(this)` function is called to register the `this` object into it, thus completing the overall registration logic.

[0037] Here, DYEvent represents the event bus, getDefault() is the constructor retrieval function, and Register(this) registers the constructor. `this` represents the object passed to the constructor; setting `this` to the synchronized class function DYLoginProxy registers the synchronized class function DYLoginProxy with the event bus DYEvent.

[0038] Optionally, the method further includes the following steps: when page loading is detected, the onActivityCreate function is called to obtain the initial login status information of the current page, and the initial login status information is assigned to the isLogin variable.

[0039] The `onActivityCreate` function can be understood as the function for obtaining the login status. Specifically, the system calls the `onActivityCreate` function when the page loads. This function can be overridden to implement some business logic and obtain the page's login status. The specific overriding method is as follows: `override fun onActivityCreate(){}`.

[0040] Within this function body, the current login status is obtained by calling the method `isLogin = UserBox.the().isLogin`, and the obtained login status is assigned to the variable `isLogin`, thus providing initial login status information. Here, the value of `isLogin` represents the login status, and `UserBox` represents the user login information storage function, which stores the user's login information. In this embodiment, the execution logic of the `onActivityCreate` function is as follows: first, the user login information storage function is called; then, the `isLogin` value under the user login information storage function is obtained; and finally, `UserBox.the().isLogin` is assigned to the `isLogin` value of the `onActivityCreate` function, thus obtaining the page login status. In this embodiment, obtaining the page login status through the user login information storage function can improve the efficiency and accuracy of obtaining the page login status.

[0041] Step 130: If the synchronization function is registered in the event bus, then the listener function is called to listen for the login status of the page.

[0042] The listener function can be defined as follows: `fun onLoginInfo(isLogin:Boolean){}`. Here, `isLogin` can be understood as the input parameter of the `onLoginInfo` function, and `Boolean` represents the data type of the input parameter `isLogin`. This input parameter `isLogin` indicates the page login status. Since the synchronous function has been registered in the event bus, when the system receives a login status message, the above-defined `onLoginInfo` function will be called back, and the page login status will be obtained through `isLogin` in the `onLoginInfo` function.

[0043] Step 140: When login status information is detected, call the broadcast function to broadcast the login status information in order to synchronize the login status information.

[0044] Specifically, the ways to broadcast login status information by calling the broadcast function can be: calling the Holder object of the broadcast function; calling the dispatchListener method in the Holder object to distribute the message; calling the filter method to filter out the target distribution module; and calling the distribution function to distribute the login status information to the target distribution module.

[0045] In this embodiment, the logic for broadcasting the login status information is as follows:

[0046]

[0047] Specifically, the principle behind the above code can be understood as follows: First, a Holder object is obtained by calling the `MZHolderManager.getActivityHolder(mContext)` method. Then, the `dispatchListener` method within it is called to dispatch messages. Next, the `filter` method is overridden to filter out the module types that need to be dispatched. Finally, the message is dispatched by calling the `listener.onProxyLogin(isLogin)` method. This ensures that login status messages are broadcast promptly and effectively when they change.

[0048] In this embodiment, when some page lifecycle states change, it is necessary to perform secondary broadcasting of the login status information. The advantage of doing so is that the login status information can be synchronized in a timely manner, ensuring that business data related to the login status can be effectively and quickly restored.

[0049] Optionally, when the page exit is detected, the onActivityFinish function is called to determine whether the synchronous class function is registered in the event bus. If it is registered, DYEvent.getDefault().unRegister(this) is called to unregister the synchronous class function.

[0050] The `onActivityFinish` function can be understood as the page exit function, used to perform operations such as memory cleanup. Specifically, when the page exits, the system will call back the `onActivityFinish` function. At this time, I can override this function to perform some cleanup operations, thereby effectively avoiding memory leaks. The specific overriding logic is as follows: `override funonActivityFinish(){}`.

[0051] In this function body, it first checks whether the synchronized class function has been registered by calling if(DYEvent.getDefault().isRegistered(this)). If it has been registered, it is unregistered; otherwise, it is not unregistered. The advantage of doing this is that it can effectively and timely release resources and avoid memory leaks.

[0052] Unregistering can be understood as unregistering. The specific function call logic for unregistering is as follows: DYEvent.getDefault().unRegister(this). The principle behind this logic can be understood as follows: first, a default unregister constructor is obtained through DYEvent.getDefault(), and then unregister(this) is called in the constructor to unregister the synchronized class function from the event bus.

[0053] Optionally, when the page is detected to have returned to the foreground from the background, the onActivityResume function is called to determine the login status of the page based on the isLogin variable, and the broadcast function is called to broadcast the login status information to synchronize the login status information.

[0054] The `onActivityResume` function can be understood as the page restoration function. Specifically, the system will call `onActivityResume` when the page is restored. Therefore, you can override this function to implement the page restoration state logic. The specific overriding method is as follows: `override fun onActivityResume(){}`.

[0055] In the above method, the login status information of the page is first determined based on the variable isLogin, and the login status information is synchronized in a timely manner. The specific synchronization method is similar to that described above, and the code is as follows:

[0056]

[0057] First, a Holder object is obtained by calling the `MZHolderManager.getActivityHolder(mContext)` method. Then, the `dispatchListener` method is called to dispatch messages. Next, the `filter` method is overridden to filter out the module types that need to be dispatched. Finally, the message is dispatched by calling the `listener.onProxyLogin(isLogin)` method. This ensures that login status messages are broadcast promptly and effectively, thus enabling timely and effective synchronization of login status information.

[0058] The technical solution of this embodiment defines a synchronization class function; the synchronization class function inherits from the system base class function; the initialization function in the synchronization class function is called to determine whether the synchronization class function is registered in the event bus; if the synchronization class function is registered in the event bus, a listening function is called to listen for the login status of the page; when login status information is detected, a broadcast function is called to broadcast the login status information to synchronize the login status information. The login status synchronization method provided by this embodiment of the invention, when the login status of the page is detected, synchronizes the login status information through broadcasting, which can synchronize the login status in a timely manner and reduce the complexity of login status synchronization.

[0059] Example 2

[0060] Figure 2 This is a schematic diagram of a login status synchronization device provided in Embodiment 2 of the present invention. Figure 2 As shown, the device includes:

[0061] Synchronization class function definition module 210 is used to define synchronization class functions; the synchronization class functions inherit from the system base class functions.

[0062] The registration judgment module 220 is used to call the initialization function in the synchronization class function to determine whether the synchronization class function is registered to the event bus;

[0063] The login status monitoring module 230 is used to call the monitoring function to monitor the login status of the page when the synchronous class function is registered in the event bus;

[0064] The login status information broadcasting module 240 is used to call a broadcast function to broadcast the login status information when it is detected, so as to synchronize the login status information.

[0065] Optionally, the registration judgment module 220 is also used for:

[0066] Get the setter constructor in the initialization function;

[0067] Determine whether the object passed in the constructor is an event bus;

[0068] If so, then whether the synchronization class function is registered to the event bus.

[0069] Optionally, it also includes: a registration module, used for:

[0070] If the synchronization function is not registered in the event bus, then the set constructor in the initialization function is obtained;

[0071] The object passed in the constructor is set as the event bus to register the synchronization class function to the event bus.

[0072] Optionally, it also includes: an initial login status information acquisition module, used for:

[0073] When page loading is detected, the onActivityCreate function is called to obtain the initial login status information of the current page and assign the initial login status information to the isLogin variable.

[0074] Optionally, the login status information broadcast module 240 is also used for:

[0075] The Holder object that calls the broadcast function;

[0076] Call the dispatchListener method in the Holder object to dispatch the message;

[0077] Call the filter method to filter out the target distribution module;

[0078] The dispatch function is invoked to distribute the login status information to the target dispatch module.

[0079] Optionally, it also includes: an unregistration module, used for:

[0080] When the page exit is detected, the onActivityFinish function is called to determine whether the synchronous class function is registered in the event bus. If it is registered, EventBus.getDefault().unRegister(this) is called to unregister the synchronous class function. Here, DYEvent is the event bus, getDefault() is the constructor retrieval function, and unRegister(this) is the unregister constructor.

[0081] Optionally, it also includes: a page recovery module, used for:

[0082] When the page is detected to have returned to the foreground from the background, the onActivityResume function is called to determine the login status of the page based on the isLogin variable, and the broadcast function is called to broadcast the login status information to synchronize the login status information.

[0083] The above-described apparatus can execute the methods provided in all the foregoing embodiments of the present invention, and has the corresponding functional modules and beneficial effects for executing the above methods. Technical details not described in detail in this embodiment can be found in the methods provided in all the foregoing embodiments of the present invention.

[0084] Example 3

[0085] Figure 3This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. Figure 3 A block diagram of a computer device 312 suitable for implementing embodiments of the present invention is shown. Figure 3 The computer device 312 shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of the present invention. Device 312 is a typical computing device for synchronizing login status.

[0086] like Figure 3 As shown, the computer device 312 is presented in the form of a general-purpose computing device. The components of the computer device 312 may include, but are not limited to: one or more processors 316, a storage device 328, and a bus 318 connecting different system components (including the storage device 328 and the processor 316).

[0087] Bus 318 represents one or more of several bus architectures, including memory buses or memory controllers, peripheral buses, graphics acceleration ports, processors, or local buses using any of the various bus architectures. Examples of these architectures include, but are not limited to, Industry Standard Architecture (ISA) buses, Micro Channel Architecture (MCA) buses, Enhanced ISA buses, Video Electronics Standards Association (VESA) local buses, and Peripheral Component Interconnect (PCI) buses.

[0088] Computer device 312 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by computer device 312, including volatile and non-volatile media, removable and non-removable media.

[0089] Storage device 328 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 330 and / or cache memory 332. Computer device 312 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 334 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 3 Not shown; usually referred to as a "hard drive"). Although Figure 3Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disc drive for reading and writing to a removable non-volatile optical disc (e.g., a Compact Disc-Read Only Memory (CD-ROM), a Digital Video Disc-Read Only Memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to bus 318 via one or more data media interfaces. Storage device 328 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.

[0090] A program 336 having a set (at least one) of program modules 326 may be stored in, for example, a storage device 328. Such program modules 326 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 326 typically perform the functions and / or methods described in the embodiments of the present invention.

[0091] Computer device 312 can also communicate with one or more external devices 314 (e.g., keyboard, pointing device, camera, display 324, etc.), and with one or more devices that enable a user to interact with the computer device 312, and / or with any device that enables the computer device 312 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 322. Furthermore, computer device 312 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN)) and / or public networks, such as the Internet) via network adapter 320. As shown, network adapter 320 communicates with other modules of computer device 312 via bus 318. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with computer device 312, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) systems, tape drives, and data backup storage systems.

[0092] The processor 316 executes various functional applications and data processing by running programs stored in the storage device 328, such as implementing the login status synchronization method provided in the above embodiments of the present invention.

[0093] Example 4

[0094] This invention provides a computer-readable storage medium storing a computer program that, when executed by a processing device, implements the gaze mapping method as described in this invention. The computer-readable medium described above can be a computer-readable signal medium, a computer-readable storage medium, or any combination thereof. The computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. The transmitted data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0095] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0096] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0097] The aforementioned computer-readable medium carries one or more programs. When the aforementioned one or more programs are executed by the electronic device, the electronic device causes the following: a synchronization class function is defined; the synchronization class function inherits from the system base class function; an initialization function is called in the synchronization class function to determine whether the synchronization class function is registered in the event bus; if the synchronization class function is registered in the event bus, a listening function is called to listen for the login status of the page; when login status information is detected, a broadcast function is called to broadcast the login status information to synchronize the login status information.

[0098] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0099] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0100] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.

[0101] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0102] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0103] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A login status synchronization method, used to synchronize the login status to at least one functional module of a web page when the login status changes, characterized in that, include: Define a synchronization class function; the synchronization class function inherits from the system base class function; Call the initialization function in the synchronization class function to determine whether the synchronization class function is registered to the event bus; If the synchronous class function is registered in the event bus, when the page load is detected, the onActivityCreate function is called to obtain the initial login status information of the current page, and the initial login status information is assigned to the isLogin variable. Here, the onActivityCreate function is the login status acquisition function, and the value of isLogin represents the login status. Call the listener function to monitor the login status of the page; When login status information is detected, a broadcast function is called to broadcast the login status information to synchronize the login status information to at least one functional module; The process of calling the broadcast function to broadcast the login status information includes: The Holder object that calls the broadcast function; Call the dispatchListener method in the Holder object to dispatch the message; Call the filter method to filter out the target distribution module; The dispatch function is invoked to distribute the login status information to the target dispatch module.

2. The method according to claim 1, characterized in that, Calling the initialization function in the synchronization class function, and determining whether the synchronization class function is registered to the event bus, includes: Get the setter constructor in the initialization function; Determine whether the object passed in the constructor is an event bus; If so, the synchronization function is registered in the event bus.

3. The method according to claim 2, characterized in that, After determining whether the synchronization function is registered in the event bus, the method further includes: If the synchronization function is not registered in the event bus, then the set constructor in the initialization function is obtained; The object passed in the constructor is set as the event bus to register the synchronization class function to the event bus.

4. The method according to claim 1, characterized in that, Also includes: When the page exit is detected, the onActivityFinish function is called to determine whether the synchronous class function is registered in the event bus. If it is registered, DYEvent.getDefault().unRegister(this) is called to unregister the synchronous class function. Here, DYEvent is the event bus, getDefault() is the constructor retrieval function, and unRegister(this) is the unregister constructor.

5. The method according to claim 1, characterized in that, Also includes: When the page is detected to have returned to the foreground from the background, the onActivityResume function is called to determine the login status of the page based on the isLogin variable, and the broadcast function is called to broadcast the login status information to synchronize the login status information.

6. A login status synchronization device, used to synchronize the login status to at least one functional module of a web page when the login status changes, characterized in that, include: The synchronization class function definition module is used to define synchronization class functions; these synchronization class functions inherit from the system base class functions. The registration judgment module is used to call the initialization function in the synchronization class function to determine whether the synchronization function is registered to the event bus; The login status monitoring module is used to call the monitoring function to monitor the login status of the page when the synchronous class function is registered to the event bus; The login status information broadcasting module is used to call a broadcast function to broadcast the login status information when login status information is detected, so as to synchronize the login status information to the at least one functional module; The device further includes: an initial login status information acquisition module, which is used to call the onActivityCreate function before calling the listening function, when the page is detected to be loading, to obtain the initial login status information of the current page, and assign the initial login status information to the isLogin variable, wherein the onActivityCreate function is the login status acquisition function, and the value of isLogin represents the login status; The login status information broadcasting module is specifically used for: calling the Holder object of the broadcast function; calling the dispatchListener method in the Holder object to distribute messages; calling the filter method to filter out the target distribution module; and calling the distribution function to distribute the login status information to the target distribution module.

7. A computer device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the login status synchronization method as described in any one of claims 1-5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processing device, the program implements the login status synchronization method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Authorized login method and device, smart device and memory medium

    CN108449357A

  • Method, apparatus and device for synchronizing login status, and computer storage medium

    WO2016101635A1