Invention content
In view of the deficiencies in the prior art, the purpose of the present invention is to provide one kind for being updated in informant in being broadcast live
Several method and a kind of system for updating online number in being broadcast live, can be conveniently to the current online number of direct broadcasting room
It is updated.
To achieve the above objectives, the technical solution adopted by the present invention is that:Including:
S1:Client is broadcast live and receives the current online number of direct broadcasting room that barrage server is sent;
S2:With agent way, by direct broadcasting room, currently online number is sent to the view controller of iOS system to live streaming client;
S3:According to the current online number of the direct broadcasting room of acquisition, view controller is dished out update with agent way to sub-interface
The notice of client UI is broadcast live, the sub-interface is that the view interface unit that informant's number is shown in client UI is broadcast live, described
The operation of dishing out of notice carries out in the main thread of live streaming client;
S4:Sub-interface obtains the notice of update live streaming client UI, carries out the update that online number is shown in sub-interface.
Based on the above technical solution, described containing execution code in the notice of the update live streaming client UI
Code is executed for being shown according to the online number in the direct broadcasting room of acquisition currently online number update sub-interface.
Based on the above technical solution, the notice of the update live streaming client UI is statement function, the execution
Code is located in the statement function, and the execution for executing code carries out in the main thread of live streaming client.
Based on the above technical solution, after the notice of update live streaming client UI is dished out:
S301:Judge whether containing code is executed in the notice of update live streaming client UI, if so, S302 is gone to, if not having
Have, then terminates;
S302:Judge whether the execution for executing code carries out in main thread, if so, S4 is gone to, if it is not, will then execute
The execution operation of code is recalled in main thread, and S4 is then gone to.
Based on the above technical solution, led to based on socket between the live streaming client and barrage server
News.
Based on the above technical solution, it throws to the current online number of the direct broadcasting room in the view controller of iOS system,
It is converted into the data type of long long types.
Based on the above technical solution, the barrage server is spaced at preset timed intervals to live streaming client and sends room
Between number change class message.
The invention also discloses a kind of systems for updating online number in being broadcast live, including:
Data reception module is used to receive barrage server to the direct broadcasting room of live streaming client transmission currently in informant
Number;
Data transmission module, is used for that currently online number to be thrown into iOS system by direct broadcasting room that data reception module receives
View controller in, and control view controller according to the direct broadcasting room of acquisition, currently to sub-interface dish out update by online number
The notice of client UI is broadcast live, and the operation of dishing out of the notice carries out in the main thread of live streaming client, the sub-interface
To be shown in the view interface unit of informant's number in live streaming client UI;
Data update module is used for the notice according to update live streaming client UI, and it is aobvious to carry out online number in sub-interface
The update shown.
Based on the above technical solution, code, institute are executed containing one in the notice of the update live streaming client UI
It states and executes code for being shown according to the online number in the direct broadcasting room of acquisition currently online number update sub-interface.
Based on the above technical solution, the barrage server is spaced at preset timed intervals to live streaming client and sends room
Between number change class message.
Compared with prior art, the present invention is a kind of is used to be the advantages of updating the method for online number in being broadcast live:Pass through
Room number variation class message is sent to live streaming client by barrage server, is currently existed between being broadcast live convenient for live streaming client
The update of informant's number, barrage server carry out the mode of message push active control, the frequency pushed to message convenient for backstage personnel
Rate is flexibly controlled;Meanwhile being acted on behalf of using two-stage, obtaining direct broadcasting room from the room number variation class message of reception currently exists
Informant's number is thrown to view controller in a manner of acting on behalf of, and view controller is dished out update live streaming client with agent way to sub-interface
The notice for holding UI, is effectively handled the distribution of event, respectively completes the transmission of dishing out of respective message, affair logic processing
Clearly;After sub-interface receives the notice of update live streaming client UI, you can complete the update of the online number of direct broadcasting room, effectively
React the current popularity of direct broadcasting room.
The present invention is a kind of to be used to be the advantages of updating the system of online number in being broadcast live:Data reception module receives bullet
The current online number of direct broadcasting room that curtain server is sent, while currently online number is thrown the direct broadcasting room received to view control
Device, view controller is dished out to sub-interface updates the notice of live streaming client UI, and sub-interface can carry out what online number was shown
The current popularity of direct broadcasting room is grasped in update convenient for main broadcaster or spectators, and entire direct broadcasting room currently divide by online number renewal process logic
It is bright and easy to implement.
Specific implementation mode
Invention is further described in detail with reference to the accompanying drawings and embodiments.
Shown in Figure 1, the embodiment of the present invention provides a kind of method for updating online number in be broadcast live, is used for pair
The update of the online number of direct broadcasting room in client is broadcast live in iOS system, in the embodiment of the present invention, live streaming client is located at operation and is
System is in the Intelligent mobile equipment of iOS system, and Intelligent mobile equipment is mobile phone or tablet computer.It specifically includes:
S1:Client is broadcast live and receives the current online number of direct broadcasting room that barrage server is sent, barrage server is with message
Form send the current online number of direct broadcasting room to live streaming client, and barrage server be sent to live streaming client message have it is more
Type, currently online number belongs to room number variation class message to direct broadcasting room.Client is broadcast live and uses function
ReceiveAssistMessageWithType receives the message that barrage server sends over, function
Parameter hostType in receiveAssistMessageWithType represents barrage clothes herein to indicate type of server
Business device.
Barrage server is sent to the type of live streaming client message, such as:Barrage word class, number change class, and number becomes
Change class is divided into changes class, room number variation class etc. for whole live streaming numbers, therefore when live streaming client receives barrage service
After the message that device is sent, function isEqualToString need to be used to judge whether the type of the message received is number variation class,
If number changes class, then relevant logical process is carried out to message, and use function
ReceiveAssistMessageWithType further judges whether message is receiveAssistMessageWithType
Type, receiveAssistMessageWithType types are expressed as room number variation class, because direct broadcasting room watches people
Several variations belongs to ground message in room, is handled in this regard, live streaming client only need to change class message to room number.
S2:With agent way, by direct broadcasting room, currently online number is sent to the view controller of iOS system to live streaming client,
It is sent to direct broadcasting room in the view controller of iOS system currently online number, is converted into the data class of long long types
Type, long long types are a kind of data types of Objective-C language, similar double types.Number variation class in room disappears
The acquisition of the current online number of direct broadcasting room passes through function [decodergetItem in breath:@" uc "], while can be by the straight of acquisition
Current online number is denoted as usercount between broadcasting.
Direct broadcasting room currently thrown by proxy function to the view controller of iOS system by online number, and proxy function is
socketKeepLive.By agent way, by direct broadcasting room, currently online number is dished out mode, special according to the agency of iOS system
Property, the agency agreement for deferring to view server only need to be acted on behalf of, while realizing-(void) socketKeepLive:(NSString*)
This function of usercount, view server just can receive the direct broadcasting room acted on behalf of and dished out currently online number, entire message
Notice and receive simple, while only needing view server currently online number message handled to direct broadcasting room, without other
Controller simplifies operation to the pre-processing of message.
S3:According to the current online number of the direct broadcasting room of acquisition, view controller is dished out update with agent way to sub-interface
The notice of client UI (User Interface, user interface) is broadcast live, live streaming client UI is to be broadcast live in Intelligent mobile equipment
The UI of client software, sub-interface are that the view interface unit that informant's number is shown in client UI is broadcast live, the behaviour that dishes out of notice
Make to carry out in the main thread of live streaming client.Code is executed containing one in the notice of update live streaming client UI, executes code
For being shown according to the online number in the direct broadcasting room of acquisition currently online number update sub-interface.According to iOS system language
Characteristic is developed, update UI must be carried out in the main thread of application, therefore, the operation of dishing out of the notice of update live streaming client UI
It is both needed to carry out in the main thread of live streaming client with the execution for executing code.View controller is for controlling live streaming client UI
Display, live streaming client UI is made of multiple view interface units, and each view interface unit displayed content classification is different,
Each corresponding sub-interface of view interface unit, sub-interface, that is, view are controlled by view controller, and view controller control is
For the ViewController in iOS system.Sub-interface is to be shown in informant's number in live streaming client UI in the embodiment of the present invention
View interface unit.
Executing code is specially:
The notice of update live streaming client UI is a statement function, executes code and is located in the statement function, and executes
The execution of code carries out in the main thread of live streaming client.Statement function is executeInMainQueue, is had in the function
One parameter block, block is to execute code.To ensure direct broadcasting room, currently online number is newer is normally carried out, when update is straight
Broadcast client UI notice dish out after:
S301:Judge whether containing code is executed in the notice of update live streaming client UI, if so, S302 is gone to, if not having
Have, then terminate, that is, declares the executive termination of function.Code is executed by judgement to whether there is, and is in order to avoid incoming one executes
Code is the situation of sky, so as to cause live streaming client-side program collapse.
S302:Judge whether the execution for executing code carries out in main thread, if so, S4 is gone to, if it is not, will then execute
The execution operation of code is recalled in main thread, and S4 is then gone to.Whether the execution for executing code passes through function in main thread
[NSThreadisMainThread] is judged, if not using function dispatch_async in main thread
(dispatch_get_main_queue (), block) recalls to the execution for executing code operation in main thread.
After the judgement for completing S301 and S302 confirms, you can be updated the process of dishing out of the notice of live streaming client UI
Operation:In executing code, setPersonNum is judged using function respondsToSelector:number:This function
Realization whether there is, and if it exists, then use function [self.danmuDelegatenumber:count];By update live streaming visitor
Family end UI is dished out with agent way to sub-interface.
S4:Sub-interface obtains the notice of update live streaming client UI, carries out the update that online number is shown in sub-interface.
It is communicated based on socket (programming interface) between live streaming client and barrage server, socket is a communication
The handle of chain, for realizing the communication between different virtual machine, different computer or distinct device, using socket by room people
For number variation class message from barrage server transport to live streaming client, the data volume of socket communications is big and rapid, and occupy
Server resource is small, can effectively ensure that the timeliness of room number variation class message transmission.Meanwhile barrage server is by default
Time interval sends room number to live streaming client and changes class message, can control, make to the renewal frequency of online number
With flexible.
Method in the embodiment of the present invention for updating online number in being broadcast live, is become room number by barrage server
Change class message and is sent to live streaming client, the update of current online number, barrage service between being broadcast live convenient for live streaming client
Device carries out the mode of message push active control, and the frequency pushed to message convenient for backstage personnel is flexibly controlled;Meanwhile making
It is acted on behalf of with two-stage, obtaining direct broadcasting room from the room number variation class message of reception, currently online number is thrown in a manner of acting on behalf of
View controller, view controller, which is dished out with agent way to sub-interface, updates the notice of live streaming client UI, effectively to thing
The distribution of part is handled, and respectively completes the transmission of dishing out of respective message, and affair logic processing is clear;Sub-interface receives update
After the notice of client UI is broadcast live, you can complete the update of the online number of direct broadcasting room, the current popularity of effecting reaction direct broadcasting room.
The embodiment of the invention also discloses a kind of based on above-mentioned for updating being used for directly for the method for online number in being broadcast live
The system for broadcasting the middle online number of update, including:Data reception module, data transmission module and data update module.
Data reception module is used to receive the current online number of direct broadcasting room that barrage server is sent to live streaming client;Number
It is used for that currently online number is sent to iOS system by proxy function by direct broadcasting room that data reception module receives according to transmission module
View controller in, and control view controller acts on behalf of letter according to the current online number of the direct broadcasting room of acquisition by another
Number is dished out the notice of update live streaming client UI to sub-interface, and notify dish out operation in the main thread of live streaming client into
Row, sub-interface are that the view interface unit that informant's number is shown in client UI is broadcast live;Data update module is used for according to update
The notice of client UI is broadcast live, carries out the update that online number is shown in sub-interface.
Code is executed containing one in the notice of update live streaming client UI, executes code for working as according to the direct broadcasting room of acquisition
Online number in preceding online number update sub-interface is shown.Barrage server is spaced at preset timed intervals to live streaming client and sends
Room number changes class message.
System in the embodiment of the present invention for updating online number in being broadcast live:Data reception module receives barrage service
The current online number of direct broadcasting room that device is sent, while currently online number is thrown the direct broadcasting room received to view controller, depending on
Figure controller is dished out to sub-interface updates the notice of live streaming client UI, and sub-interface can carry out the update that online number is shown,
The current popularity of direct broadcasting room is grasped convenient for main broadcaster or spectators, currently online number renewal process logic is clearly demarcated for entire direct broadcasting room, and
It is easy to implement.
The present invention is not limited to the above-described embodiments, for those skilled in the art, is not departing from
Under the premise of the principle of the invention, several improvements and modifications can also be made, these improvements and modifications are also considered as the protection of the present invention
Within the scope of.The content not being described in detail in this specification belongs to the prior art well known to professional and technical personnel in the field.