The content of the invention
For defect present in prior art, it is used for live middle renewal in informant it is an object of the invention to provide one kind
Several method and a kind of for the live middle system for updating online number, being capable of conveniently online number current to direct broadcasting room
It is updated.
To achieve the above objectives, the present invention is adopted the technical scheme that:Including:
S1:Live client receives the current online number of direct broadcasting room that barrage server is sent;
S2:Live client is sent the current online number of direct broadcasting room to the view controller of iOS system with agent way;
S3:According to the current online number of the direct broadcasting room of acquisition, view controller is dished out renewal with agent way to sub-interface
Live client UI notice, the sub-interface is described to be shown in the view interface unit of informant's number in live client UI
The operation of dishing out notified is carried out in the main thread of live client;
S4:Sub-interface obtains the notice for updating live client UI, carries out the renewal that online number is shown in sub-interface.
It is described containing code is performed in the notice for updating live client UI on the basis of above-mentioned technical proposal
The online number that performing code is used in the current online number renewal sub-interface of direct broadcasting room according to acquisition is shown.
On the basis of above-mentioned technical proposal, the notice for updating live client UI is statement function, the execution
Code is located in the statement function, and the execution for performing code is carried out in the main thread of live client.
On the basis of above-mentioned technical proposal, after the notice for updating live client UI is dished out:
S301:Whether judge to update in live client UI notice containing code is performed, if so, S402 is gone to, if not having
Have, then terminate;
S302:Judge whether the execution for performing code is carried out in main thread, if so, S4 is gone to, if it is not, will then perform
The execution operation of code is recalled in main thread, then goes to S4.
On the basis of above-mentioned technical proposal, led between the live client and barrage server based on socket
News.
On the basis of above-mentioned technical proposal, the current online number of direct broadcasting room into the view controller of iOS system is thrown,
It is converted into the data type of long long types.
On the basis of above-mentioned technical proposal, the barrage server is spaced to live client and sends room at preset timed intervals
Between number change class message.
The invention also discloses a kind of for the live middle system for updating online number, including:
Data reception module, it is current in informant that it is used to receiving the direct broadcasting room that barrage server sends to live client
Number;
Data transmission module, its current online number of direct broadcasting room for being used to receive data reception module is thrown into iOS system
View controller in, and control view controller dishes out renewal according to the current online number of the direct broadcasting room of acquisition to sub-interface
Live client UI notice, and dish out the operation progress, the sub-interface in the main thread of live client of the notice
To be shown in the view interface unit of informant's number in live client UI;
Data update module, it is used for according to the notice for updating live client UI, carries out online people's digital display in sub-interface
The renewal shown.
On the basis of above-mentioned technical proposal, code, institute are performed containing one in the notice for updating live client UI
The online number that stating execution code is used in the current online number renewal sub-interface of direct broadcasting room according to acquisition is shown.
On the basis of above-mentioned technical proposal, the barrage server is spaced to live client and sends room at preset timed intervals
Between number change class message.
Compared with prior art, a kind of advantage for the live middle method for updating online number of the present invention is:Pass through
Room number change class message is sent to live client by barrage server, is easy to live client to carry out direct broadcasting room and is currently existed
The renewal of informant's number, barrage server carries out the mode that message pushes active control, the frequency for being easy to backstage personnel to push message
Rate is flexibly controlled;Meanwhile, acted on behalf of using two-stage, obtaining direct broadcasting room from the room number change class message of reception currently exists
Informant's number is thrown to view controller in the way of acting on behalf of, and view controller is dished out the live client of renewal with agent way to sub-interface
UI notice is held, the effectively distribution to event is handled, each complete the transmission of dishing out of respective message, affair logic processing
Clearly;Sub-interface is received after the notice for updating live client UI, you can complete the renewal of the online number of direct broadcasting room, effectively
React the current popularity of direct broadcasting room.
A kind of advantage for the live middle system for updating online number of the present invention is:Data reception module receives bullet
The current online number of direct broadcasting room that curtain server is sent, while the current online number of the direct broadcasting room received is thrown to view control
Device, view controller is dished out to sub-interface updates live client UI notice, and sub-interface can carry out what online number was shown
Update, be easy to main broadcaster or spectators to grasp the current popularity of direct broadcasting room, the current online number renewal process logic point of whole direct broadcasting room
It is bright and easy to implement.
Embodiment
The present invention is described in further detail below in conjunction with drawings and Examples.
Shown in Figure 1, the embodiment of the present invention provides a kind of for the live middle method for updating online number, for pair
In iOS system in live client the online number of direct broadcasting room renewal, in the embodiment of the present invention, live client is located at operation and is
Unite as in the Intelligent mobile equipment of iOS system, Intelligent mobile equipment is mobile phone or tablet personal computer.Specifically include:
S1:Live client receives the current online number of direct broadcasting room that barrage server is sent, and barrage server is with message
Form send the current online number of direct broadcasting room to live client, and barrage server is sent to live client message many
Type, the current online number of direct broadcasting room belongs to room number change class message.Live client uses function
ReceiveAssistMessageWithType receives the message that barrage server is sended over, function
Parameter hostType in receiveAssistMessageWithType represents barrage clothes to represent type of server, herein
Business device.
Barrage server is sent to the type of live client message, such as:Barrage word class, number change class, number become
Change class and be divided into all live number change class, room number change class etc. again, therefore when live 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 change class,
If number changes class, then related logical process is carried out to message, and use function
ReceiveAssistMessageWithType determines whether whether message is receiveAssistMessageWithType
Type, receiveAssistMessageWithType types are to be expressed as room number change class, because direct broadcasting room watches people
Several changes belongs to ground message in room, in this regard, live client need to be only handled room number change class message.
S2:Live client is sent the current online number of direct broadcasting room to the view controller of iOS system with agent way,
The current online number of direct broadcasting room into the view controller of iOS system is sent, the data class of long long types is converted into
Type, long long types are a kind of data type of Objective-C language, similar double types.Number change class in room disappears
The acquisition of the current online number of direct broadcasting room passes through function [decoder getItem in breath:@" uc "], while can be by acquisition
The current online number of direct broadcasting room is designated as usercount.
The current online number of direct broadcasting room is thrown to the view controller of iOS system by proxy function, and proxy function is
socketKeepLive.The current online number of direct broadcasting room is dished out mode by agent way, it is 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 realization-(void) socketKeepLive:(NSString*)
This function of usercount, view server just can receive the current online number of direct broadcasting room that agency dishes out, whole message
Notice and receive simple, while only needing view server online number message current to direct broadcasting room to handle, without other
Controller is handled the early stage of message, simplifies operation.
S3:According to the current online number of the direct broadcasting room of acquisition, view controller is dished out renewal with agent way to sub-interface
The notice of live client UI (User Interface, user interface), live client UI is live in Intelligent mobile equipment
The UI of client software, sub-interface is to be shown in the view interface unit of informant's number, the behaviour that dishes out of notice in live client UI
Make to carry out in the main thread of live client.Update in live client UI notice containing an execution code, perform code
The online number in sub-interface is updated for the current online number of the direct broadcasting room according to acquisition to show.According to iOS system language
Characteristic is developed, updating UI must be carried out in the main thread of application, therefore, update the operation of dishing out of live client UI notice
It is both needed to carry out in the main thread of live client with the execution for performing code.View controller is used to control live client UI
Display, live client UI is made up of multiple view interface units, and each view interface unit displayed content classification is different,
Each view interface unit corresponds to a sub-interface, and sub-interface is view, by view controller control, and view controller control is
For the ViewController in iOS system.In the embodiment of the present invention sub-interface be live client UI in be shown in informant's number
View interface unit.
Performing code is specially:
It is a statement function to update live client UI notice, performs code and is located in the statement function, and performs
The execution of code is carried out in the main thread of live client.Statement function is executeInMainQueue, is had in the function
One parameter block, block is execution code.It is straight when updating to ensure being normally carried out for the current online number renewal of direct broadcasting room
Broadcast client UI notice dish out after:
S301:Whether judge to update in live client UI notice containing code is performed, if so, S402 is gone to, if not having
Have, then terminate, that is, declare the executive termination of function.It is in order to avoid an incoming execution by judging that performing code whether there is
Code is empty situation, so as to cause live client-side program to collapse.
S302:Judge whether the execution for performing code is carried out in main thread, if so, S4 is gone to, if it is not, will then perform
The execution operation of code is recalled in main thread, then goes to S4.Whether the execution for performing 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 operation for performing code in main thread.
After the judgement for completing S401 and S402 confirms, you can be updated the process of dishing out of live client UI notice
Operation:In code is performed, setPersonNum is judged using function respondsToSelector:number:This function
Realization whether there is, if in the presence of using function [self.danmuDelegatenumber:count];Live visitor will be updated
Family end UI is dished out with agent way to sub-interface.
S4:Sub-interface obtains the notice for updating live client UI, carries out the renewal that online number is shown in sub-interface.
Communicated between live client and barrage server based on socket (DLL), 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
Number change class message is from barrage server transport to live client, and the data volume of socket communications is big and rapid, and take
Server resource is small, can effectively ensure that the ageing of room number change class message transmission.Meanwhile, barrage server is by default
Time interval sends room number change class message to live client, so that the renewal frequency of online number can be controlled, makes
With flexible.
It is used for the live middle method for updating online number in the embodiment of the present invention, is become room number by barrage server
Change class message and be sent to live client, be easy to live client to carry out the renewal of the current online number of direct broadcasting room, barrage service
Device carries out the mode that message pushes active control, is easy to backstage personnel flexibly to control the frequency that message is pushed;Meanwhile, make
Acted on behalf of with two-stage, the current online number of direct broadcasting room is obtained from the room number change class message of reception and is thrown in the way of acting on behalf of
View controller, view controller is dished out with agent way to sub-interface updates live client UI notice, effectively to thing
The distribution of part is handled, and each completes the transmission of dishing out of respective message, and affair logic processing is clear;Sub-interface receives renewal
After live client UI notice, you can complete the renewal 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 being used for directly for the live middle method for updating online number
The middle system for updating online number is broadcast, 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 client;Number
The current online number of direct broadcasting room for being used to receive data reception module according to transport module is sent to the view controller of iOS system
In, and control view controller dishes out the live client UI of renewal according to the current online number of the direct broadcasting room of acquisition to sub-interface
Notice, and notify dish out operation in the main thread of live client carry out, sub-interface be live client UI in show
The view interface unit of online number;Data update module is used to, according to the notice for updating live client UI, carry out sub-interface
In the renewal that shows of online number.
Update in live client UI notice containing an execution code, performing code is used to be worked as according to the direct broadcasting room of acquisition
The online number that preceding online number is updated in sub-interface is shown.Barrage server is spaced to live client and sent at preset timed intervals
Room number change class message.
It is used for the live middle system for updating online number in the embodiment of the present invention:Data reception module receives barrage service
The current online number of direct broadcasting room that device is sent, while the current online number of the direct broadcasting room received is thrown to view controller, depending on
Figure controller is dished out to sub-interface updates live client UI notice, and sub-interface can carry out the renewal that online number is shown,
It is easy to main broadcaster or spectators to grasp the current popularity of direct broadcasting room, the current online number renewal process logic of whole direct broadcasting room is clearly demarcated, 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
On the premise of the principle of the invention, some 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 prior art known to professional and technical personnel in the field.