look at the GS thread againvoidgameserver::P rocessthreadtry () {intNcount =0; Packet rcvpkt; Rcvpkt.data=New Char[1024x768* -]; //the event factory mainly created two timer 1.livemgr detection (i.e. whether it is a valid connection) 2. Prop gang the acquisition of the difference update data is timed to get the difference from the Prop gang container. This data that needs to be saved to the database//3. Release the processing of the queue, now the player offline is not directly to remove the channel, but put in the release queue medium No database access when the deletion, to prevent database callbacks appear wild pointeri_timerfactory* ptimefactory =Getplug (timerfactory); for (;;) {Procmapsenddata ();//handle the Gamemap inside the package (should be processed by all map sent packets, the process needs to see)M_spasyndbc->drive ();//Database Callback Driver BOOLBrcvret = Processloop (RCVPKT);//handling packets sent over the network layerProcmapsenddata ();//handle the package that the map sends over here (I don't know why it was executed once) if(Brcvret)//It seems that the priority is to deal with map, network, database data{m_spsaveoptmgr->driver ();//Prop Gang store database driverptimefactory->drivetimer ();//timing drivers for three things above /** * [description]: Multi-process mode, there may be unallocated successfully shared memory and lead to failure, * need GS side to help not complete the sent GC send data, otherwise there may be data loss phenomenon, * Watch the Dead loop*/ ////Since it's free, see if there's any data that hasn't been sent out . if(M_quegcwait.empty ())//first judge the feeling so good, if with the following to put together a high degree of coupling { if(m_bstopwork) Break; Boost::this_thread::interruptible_wait (1);//STL error is too large, with this high precision//test2 Continue; } intnMaxCount =5;//perform a maximum of 5 GC sends Do //Be careful not to have a dead loop { intNchannelid =M_quegcwait.front (); M_quegcwait.pop (); Gamechannel* PGC =M_vecchannel[nchannelid]; //if the GC is online and alive, send data that is not sent successfully, or empty the instruction. if(M_livemgr.islive (nchannelid) && PGC)//not be kicked off the downline and onlinePgc->Sendcmdtry (); ElsePGC->clearcmd ();//not online (traverse the remaining queue and return the memory pool)} while(M_quegcwait.size () &&--nmaxcount);//m_quegcwait failed to send a successful GC queue} ncount++; if(Ncount > -) {ptimefactory->drivetimer ();//when more than 50 time to force the driver timer, otherwise the above several busy time, this timer has not been driven, the correlation function has been unable to executeNcount =0; }} stopwork (); Delete[] rcvpkt.data;}BOOLGameserver::P Rocessloop (packet&rpkt) { if(false= = M_spdatalayer->Recv (RPKT))return true;//no data. if(rpkt.is_data) {if(!rpkt.data)return false; Gamechannel* PGC =m_vecchannel[rpkt.channel_id]; if(PGC) PGC-Onreceivedata (Rpkt.data, rpkt.size); M_livemgr.onlive (rpkt.channel_id); } Else { //Network EventsLink_stat stat =(Link_stat) rpkt.size; if(Stat = =link_stat::link_connected) {Gamechannel* PNEWGC =NewGamechannel (); PNEWGC->m_nchannelid =rpkt.channel_id; PNEWGC->m_pdatalayer = M_spdatalayer.Get(); PNEWGC->m_pshare = This; PNEWGC->M_PASYNDBC = This->m_spasyndbc.Get(); PNEWGC->m_plog = This->m_splog.Get(); M_VECCHANNEL[RPKT.CHANNEL_ID]=PNEWGC; M_livemgr.add (rpkt.channel_id); } Else if(stat = = Link_stat::link_disconnected | | stat = =link_stat::link_connect_failed) {Gamechannel* PDISCONNECTGC =m_vecchannel[rpkt.channel_id]; if(PDISCONNECTGC) {//If you enter the map, you will be called Push_freequeue + hysteresis m_channels[channel_id] When you save the character information .Pdisconnectgc->OnDisconnect (); //if the map is not in the offline, directly disconnected; Do not save role details, can be placed directly in the release queue if(!pdisconnectgc->M_pmap) {AUTOFREEGC (PDISCONNECTGC); }} m_livemgr.remove (rpkt.channel_id); } } return false;}
Look at the GS thread again