Disclosure of Invention
In view of the problems in the prior art, an object of the present invention is to provide a method, a system, a server, and a storage medium for optimizing list information of a live broadcast platform, where the method employs a message subscription mode, a client sends a subscription message to the server if the list information is needed according to a current scene of the client, the server sends a first half of the list information to the client at this time, and when the client slides according to the list or needs to check more list information, the client sends an interval range of the subscription message, and the server sends range data that can be displayed according to the client. The message is cancelled when the client does not need a subscription. The method includes the steps that a server actively issues list messages, the client side issues the list messages according to the requirements of a user, relevant list information is requested from the server when list data are needed, and meanwhile the list data are dynamically requested according to the display range and the size of a user screen.
In order to achieve the purpose, the technical scheme adopted by the invention is a method for optimizing list information of a live broadcast platform, and the method comprises the following steps:
s1, logging in a live broadcast platform by the client to acquire the screen resolution of the client;
s2, the client live broadcast platform sends a subscription request and screen resolution to the server to subscribe the list data, or sends a unsubscribe request to the server to unsubscribe the list data;
s3, after receiving subscription information of the client, the server adds the unique ID of the user at the client into a subscription linked list, if the user subscribes the list data, the list data is issued, and if the user cancels the subscription, the unique ID of the user is deleted;
s4, the server issues corresponding list data according to the subscription client side in the step S3, wherein the issued list data need to be calculated according to the screen resolution of the corresponding client side, and the data of the final list are obtained and sent to the client side;
and S5, after receiving the final list data, the client displays the list page of the live broadcast platform.
In the above technical solution, the acquiring of the screen resolution in step S1 includes the following steps:
s11, acquiring a window management server object through an Api function GetSystemservice;
s12, obtaining a screen resolution object through a window management server object calling function GetDefaultDisplay;
and S13, acquiring the width and the height of the screen through the screen resolution object.
In the above technical solution, in the step S3, the server stores the unique ID of the subscriber client user by using the data structure linked list of the STL.
In the above technical solution, the storing the subscriber by the STL data structure linked list includes the following steps:
s31, defining and storing a subscription linked list structure ListSubscribeUserId, and defining an interface to receive user subscription information;
s32, after receiving the user subscription information, inquiring whether the unique ID of the user exists or not by defining an iterator;
and S33, if the unique ID of the subscriber is inquired, sending the list data, and if the unique ID of the subscriber is not inquired, adding the list data into the subscription linked list and then sending the list data.
In the above technical solution, the processing of the unique ID of the unsubscribe user by the STL data structure linked list includes the following steps:
s34, inquiring whether the unique ID exists through the iterator;
and S35, if the unique ID of the subscription user is inquired, deleting the unique ID from the subscription linked list.
In the above technical solution, the step S4 includes obtaining the number of the final pieces of the list data that need to be sent by dividing the height information of the screen received by the server by each piece of the list data with a fixed height.
In the above technical solution, the S5 includes the following steps:
s51, creating an instance object of the message analysis class to analyze the acquired list data;
s52, analyzing the type of the acquired list data;
and S53, displaying the acquired detailed data on the list page item by item.
The invention also discloses a system for optimizing the list information of the live broadcast platform, which comprises an acquisition module, a setting module, a storage module, a calculation module and a display module;
the acquisition module is used for logging in a live broadcast platform by a client and acquiring the screen resolution of the client;
the client live broadcast platform sends a subscription request and screen resolution to the server to subscribe the list data, or sends a subscription cancellation request to the server to cancel the subscription list data;
the storage module is used for adding the unique ID of the user at the client into a subscription linked list after the server receives the subscription information of the client, issuing list data if the user subscribes the list data, and deleting the unique ID of the user if the user cancels the subscription;
the server sends the corresponding list data according to the subscription client, wherein the sent list data needs to be calculated according to the screen resolution of the corresponding client, and the data of the final list is obtained and sent to the client;
and the display module is used for displaying the list page of the live broadcast platform after the client receives the final list data.
The invention discloses a server of a live platform list information optimization system, which comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, wherein the processor realizes the steps of any one of the live platform list information optimization methods when executing the computer program.
The invention discloses a computer-readable storage medium, which stores a computer program, wherein the computer program is executed by a processor to realize the steps of any one of the above method for optimizing the list information of the live broadcast platform.
The invention discloses a method, a system, a server and a storage medium for optimizing list information of a live broadcast platform, which have the following beneficial effects: according to the method, the list data is subscribed to the server or cancelled according to the request of the client user, so that the pressure of the server and the network downlink flow are greatly reduced, and meanwhile, the client does not need to actively receive the list data when the list data is not needed, so that the performance of the client is greatly optimized.
Detailed Description
The invention provides a method, a system, a server and a storage medium for optimizing list information of a live broadcast platform.
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention as shown in fig. 1 provides a method for optimizing list information of a live platform, which includes the following steps:
s1, logging in a live broadcast platform by the client to acquire the screen resolution of the client;
the number of the lists that can be displayed on one page of one terminal device is limited, for example, for an IPAD, 10 viewers of the lists may be displayed on one page, and for a mobile phone device, only 5 viewers of the lists may be displayed, so that the screen resolution of the client affects the display of the list data of the live platform. When a client logs in a live broadcast platform, the size of a screen of the client needs to be acquired and reported to a server, the server issues data volume according to screen resolution, and the specific acquisition of the screen resolution comprises the following steps:
s11, acquiring a window management server object through an Api function GetSystemservice;
wherein, the window manager wm is (window manager) getsysteservi ce (context.window _ SERVICE), wherein the parameter context.window _ SERVICE represents obtaining the window management SERVICE, and the obtained return value is the window management server object;
s12, obtaining a screen resolution object through a window management server object calling function GetDefaultDisplay; wherein, Display is wm, getdefaultdisplay lay (), so as to obtain the resolution object Display of the window.
And S13, acquiring the width and the height of the screen through the screen resolution object. height ═ displ ay. getwidth (); getheight (); wherein height is the height of the screen, and width is the width of the screen.
Wherein, wm. When the screen direction is switched, the width and height change. And obtaining the screen resolution according to the acquired screen width and height.
S2, the client live broadcast platform sends a subscription request and screen resolution to the server to subscribe the list data, or sends a unsubscribe request to the server to unsubscribe the list data;
the server does not actively issue list information to the client, after logging in a live broadcast platform through the client, the client displays the detailed information, the client sends subscription information to the server according to the current scene of the client if the list information is needed, the server sends the first half part of the list information to the client at the moment, when the client slides according to the list or needs to check more list information, the server sends the interval range of the subscription information, and the server sends range data which can be displayed according to the client;
optionally, the message that the client subscribes the list to the server is as follows: the subscription list message comprises a type @/id @/height @/420/width @/460, wherein the message type is type @ subframe represents the subscription message, and wherein the id @ subframe represents the subscription list message. Where height @ 420 denotes the height of the screen size, where width @ 460 denotes the width of the screen size. After the message is sent to the server, the server considers that the client requests the list message of the server, and then the server sends the list information to the client subsequently.
Optionally, the message for canceling the subscription list is as follows: the subscription cancellation message is a subscription cancellation message, and the subscription cancellation list message is a subscription cancellation list message. When the client leaves the list page, the subscription of the list can be cancelled because the information of the list is not used, so that the server does not send the list information to the client when the server changes the list information, and the client does not receive the list information any more.
By setting subscription and canceling subscription information, the pressure of the server and the network downlink flow are greatly reduced, and meanwhile, the client does not need to actively receive the list data when the list data is not needed, so that the performance of the client is optimized.
S3, after receiving subscription information of the client, the server adds the unique ID of the user at the client into a subscription linked list, if the user subscribes the list data, the list data is issued, and if the user cancels the subscription, the unique ID of the user is deleted;
optionally, in step S3, the server stores the unique ID of the subscribing client user by using the data structure linked list of the STL. The STL data structure stores all the unique IDs of the users needing to be issued, the unique IDs of the users are added when the users register, and the unique IDs of the users are deleted when the users cancel. The use of the STL data structure for storing user unique IDs further eases server stress for frequent delete and join operations that users have.
Wherein, the STL data structure linked list storing the subscribing users comprises the following steps:
s31, defining and storing a subscription linked list structure ListSubscribeUserId, and defining an interface to receive user subscription information; wherein the interface is defined as Void AddUserId (int userid).
S32, after receiving the user subscription information, inquiring whether the unique ID of the user exists or not by defining an iterator;
and S33, if the unique ID of the subscriber is inquired, sending the list data, and if the unique ID of the subscriber is not inquired, adding the list data into the subscription linked list and then sending the list data.
Wherein, Stl < int >: iterator itr ═ listSubscribeUserI d.begin (), initializing iterator as head node of chain table;
For(;itr!=listSubscribeUserId.end();++itr){
traversal is then performed through a for loop until the end of the linked list.
If ((' itr) ═ userid) { If the node currently traversed in the linked list is equal to the unique ID of the user to be added, then this user is already in the linked list. No further direct return is needed.
Return;
}
}
The user is not found to be added to the linked list until the linked list traversal is finished.
listSubscribeUserId.push_back(userid);
}。
The processing of the unique ID of the unsubscribed user by the STL data structure linked list comprises the steps of:
s34, inquiring whether the unique ID exists through the iterator;
and S35, if the unique ID of the subscription user is inquired, deleting the unique ID from the subscription linked list.
Optionally, the Void SubUserId (int userid) front page
An iterator is first written to query whether the current userid already exists.
Stl::list<int>::iterator itr=listSubscribeUserId.begi n();
The iterator is initialized to the head node of the linked list.
For(;itr!=listSubscribeUserId.end();++itr){
Traversal is then performed through a for loop until the end of the linked list.
If ((' itr) ═ userid) { If the node currently traversed in the linked list is equal to the unique ID of the user to be added, then this user is already in the linked list. Then the deletion is made from the linked list.
listSubscribeUserId.erase(itr);
Return;
}
}
S4, the server issues corresponding list data according to the subscription client side in the step S3, wherein the issued list data need to be calculated according to the screen resolution of the corresponding client side, and the data of the final list are obtained and sent to the client side;
in step S4, the calculation process includes obtaining the number of the final pieces of the list data that need to be sent by dividing the height information of the screen received by the server by each piece of the list data with the fixed height.
Specifically, in the subscription message sent by the user, the client uploads the screen resolution of the client, the server obtains the height of the client, the height occupied by each list data is fixed, and the server divides the height of each list according to the height of the client to obtain how much list protocol data the client needs to issue.
Int num ═ Height/size; height is the height reported by the client, size is the height of each list data, and the number of lists that can be displayed on one screen is num. And after the client subscribes the list message, the server issues list data of the first page to the client. And when the client requests the second page list, the server selects the data of the second page from the subsequent data of the list and issues the data to the client.
Assuming that the list messages are stored in buf, the server needs a link chain table to send all the list messages.
Stl::list<int>::iterator itr=listSubscribeUserId.begi n();
The iterator is initialized to the head node of the linked list.
For(;itr!=listSubscribeUserId.end();++itr){
sendData((*itr),buff);
And then issuing list detailed data to the user through a senddata interface.
}
}
And S5, after receiving the final list data, the client displays the list page of the live broadcast platform.
Wherein the S5 includes the steps of:
s51, creating an instance object of the message analysis class to analyze the acquired list data;
s52, analyzing the type of the acquired list data;
and S53, displaying the acquired detailed data on the list page item by item.
Specifically, an instance object of the message parsing class DataDecoder is created.
Data decoder pDecoder ═ new data decoder (); analyzing the message of the gift;
the analysis process is to decode the network protocol of the server to obtain each field and content of the protocol, the network protocol is encoded, and the client decodes the message after receiving the message.
Such as message: type @/loginreq/username @ 189470287/ct @ 2/passwo rd @/roomid @ 99999, where Type @ loginreq indicates that the Type of message is a login request message and username @ 189 is 189 where the user name is 189.
pDecoder- > Parse (buf); and buf represents the received list network message. After analysis, obtaining the message type of the message;
std::string count=std::string(pDecoder->GetItem("uidc ount"));
wherein the message field "uidcount" is obtained to get the number of spectators on the list. And analyzing the specific detailed data type of the list of the message:
string name=pDecoder->GetItemAsString(“name”);
string pic=pDecoder->GetItemAsString(“pic”);
int nNum=pDecoder->GetItemAsString(“gift”);
the name is the nickname of the user in the list, the pic is the head portrait picture of the user in the list, the gift is the contribution value of the user in the list, and the client displays the live list page after acquiring the data.
The second embodiment of the invention provides a live broadcast platform list information optimization system, which comprises an acquisition module, a setting module, a storage module, a calculation module and a display module, wherein the acquisition module, the setting module, the storage module, the calculation module and the display module are shown in fig. 2;
the acquisition module is used for logging in a live broadcast platform by a client and acquiring the screen resolution of the client;
the client live broadcast platform sends a subscription request and screen resolution to the server to subscribe the list data, or sends a subscription cancellation request to the server to cancel the subscription list data;
the storage module is used for adding the unique ID of the user at the client into a subscription linked list after the server receives the subscription information of the client, issuing list data if the user subscribes the list data, and deleting the unique ID of the user if the user cancels the subscription;
the server sends the corresponding list data according to the subscription client, wherein the sent list data needs to be calculated according to the screen resolution of the corresponding client, and the data of the final list is obtained and sent to the client;
and the display module is used for displaying the list page of the live broadcast platform after the client receives the final list data.
Fig. 3 shows a schematic structural diagram of a server of a live broadcast platform list information optimization system, where the server in the embodiment of the present invention includes: aprocessor 30, amemory 31 and acomputer program 32 stored in saidmemory 31 and executable on saidprocessor 30. The steps of the above-described method embodiments are implemented when theprocessor 30 executes thecomputer program 32, and the functions of the modules of the above-described apparatus embodiments are implemented when theprocessor 30 executes thecomputer program 32.
The server of the live platform list information optimization system can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices, and the server of the live platform list information optimization system can include, but is not limited to, aprocessor 30 and amemory 31. Fig. 3 is only an example of the server, and does not constitute a limitation to the server, and may include more or less components than those shown, or combine some components, or different components, and the server of the live platform list information optimization system may further include an input andoutput device 33, adisplay device 34, and the like.
Theprocessor 30 may be a central processing unit, but may also be other general purpose processors, digital signal processors, application specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Thestorage 31 may be an internal storage unit, a hard disk, or an internal memory of a server of the live platform list information optimization system. Thememory 31 may also be an external storage device of the server, or a plug-in hard disk, a smart card, a secure digital card, a flash memory card, etc. may be provided.
Further, thememory 31 may also include both an internal storage unit of the server and an external storage device. Thememory 31 is used for storing the computer program and other programs and data required by the electronic device. Thememory 31 may also be used to temporarily store data that has been output or is to be output.
The input/output device 33 may be used to receive input numeric or character information, and specifically, the input/output device 33 may further include one or more of a keyboard, a mouse, a joystick, and the like.
Thedisplay device 34 may be used to display information input by the user or various menus provided to the user and the terminal, and thedisplay device 34 may include a display panel, and optionally, a liquid crystal display.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the system described above may refer to the corresponding process in the foregoing method embodiment, and is not described herein again.
Those of ordinary skill in the art will appreciate that the modules, method steps, and so forth of the various embodiments described in connection with the embodiments disclosed herein can be implemented as electronic hardware, or combinations of computer software and electronic hardware. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, etc. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.