⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 station_8h-source.html

📁 用来介绍ZIG Library游戏网络引擎的文档
💻 HTML
📖 第 1 页 / 共 4 页
字号:
00431 00432         <span class="comment">//NL GROUP for the socket (workaround for blocking UDP socket with concurrent </span>00433         <span class="comment">//nlSetRemoteAddress() &amp; nlRead() accesses)</span>00434         NLint                           sock_group;00435 00436         <span class="comment">//the socket. if NL_INVALID, not opened/valid</span>00437         NLsocket                sock;00438 00439         <span class="comment">//addresses of the socket</span>00440         NLaddress               local_addr;00441         NLushort                local_port;00442         NLaddress               remote_addr;00443         NLushort                remote_port;00444 00445         <span class="comment">//address of last nlRead()</span>00446         NLaddress               last_received_addr;00447 00448         <span class="comment">//the UDP send buffer</span>00449         <a class="code" href="classbuffer__c.html">buffer_c</a>                sendbuf;00450 00451         <span class="comment">//NEW: secondary UDP send buffer for the compressed version of "sendbuf"</span>00452         <span class="comment">//char        sendbuf_zipped[ZIG_ULTIMATE_UDP_PACKET_SIZE_LIMIT];</span>00453         <span class="comment">//NEW (v1.3.0): eliminate memory wastage and need for the fixed size</span>00454         <a class="code" href="classbuffer__c.html">buffer_c</a>    sendbuf_zipped_b;00455 00456         <span class="comment">// the packet buffer's unreliable data</span>00457         <a class="code" href="classbuffer__c.html">buffer_c</a>    unrelbuf;00458 00459         <span class="comment">//ids</span>00460         NLushort                idgen_reliable_send;            <span class="comment">// outgoing reliable messages id generator</span>00461         NLushort                idgen_packet_send;                      <span class="comment">// outgoing packet id generator</span>00462         NLushort                idgen_request_send;                     <span class="comment">// outgoing request id generator</span>00463 00464         <span class="comment">// packets received with reliable messages that need acks to be sent</span>00465         std::vector&lt;NLushort&gt;   ackbuf;00466         mutex_c                                                                 ackbuf_mutex;                           <span class="comment">//mutex for ackbuf</span>00467 00468         <span class="comment">// INCOMING messages queue</span>00469         <span class="comment">// - fixed size &amp; circular (fastest insert &amp; retrieve, waste memory but memory is cheap)</span>00470         <span class="comment">// - "sliding window": can only always retrieve the next message in the number sequence ("current")</span>00471         <span class="comment">// - too many messages: messages start to be ignored until app picks them up</span>00472         <span class="comment">//   OR: receiving message greater than current+bufcap : discard</span>00473         <span class="comment">// - old messages (&lt; current) discarded</span>00474         <span class="comment">// - dup messages : will be discovered when trying to put it into the queue (will already have</span>00475         <span class="comment">//   been inserted)</span>00476         <a class="code" href="classbuffer__c.html">buffer_c</a>        message[MAX_INCOMING_MESSAGES];00477         NLushort                msg_current;            <span class="comment">// current expected message id - 3/march/2004: changed from NLulong to fix a warning</span>00478 00479         <span class="comment">// the packet buffer's reliable messages (OUTGOING)</span>00480         <span class="comment">// also works as the "messages yet to be acked" list</span>00481         <span class="comment">// since all unacked messages are always sent, this includes those that were not sent a single time yet.</span>00482         <span class="keyword">typedef</span> std::deque&lt;omsg_c&gt; reliables_list_t;00483         reliables_list_t        reliable;00484 00485         <span class="comment">//"reliable" list mutex</span>00486         mutex_c rel_mutex;00487 00488         <span class="comment">// id of outgoing messages that have been acked by the receiver, and whose acks are being</span>00489         <span class="comment">// expected by us. FIFO.</span>00490         std::deque&lt;int&gt;  racks;00491 00492         <span class="comment">// buffer for storing pending responses to requests</span>00493         <span class="comment">// map: &lt;request id ---&gt; response buffer*&gt;</span>00494         <span class="comment">//   response_buffer* is &gt;0 if : contains a response that WILL be consumed by the request thread</span>00495         <span class="comment">//   response_buffer* is  0 if : is waiting for a response to be consumed by the request</span>00496         <span class="comment">//   response_buffer* is REQUEST_TIMED_OUT if : if the request has given up (response must be discarded if it arrives)</span>00497         <span class="comment">//               (the "-1" case was created to prevent the map from getting filled with dead responses)</span>00498         <span class="comment">//map&lt;int, buffer_c*&gt;  resps;</span>00499         <span class="comment">/*</span>00500 <span class="comment"></span>00501 <span class="comment">                trying again....</span>00502 <span class="comment"></span>00503 <span class="comment">                entry does not exist: if the request has given up (response must be discarded if it arrives) OR</span>00504 <span class="comment">                   there is no request for an incoming response. discard the response !!!!</span>00505 <span class="comment">                entry exists: </span>00506 <span class="comment">                        if buffer's code is 1, then it's the answer for the request, request thread must consume this.</span>00507 <span class="comment">                        if buffer's code is 0, then is waiting for a response to arrive and be stored here</span>00508 <span class="comment"></span>00509 <span class="comment">        */</span>00510         std::map&lt;int, buffer_c&gt;  resps;00511 00512         <span class="comment">//lock for accessing the resps map</span>00513         mutex_c         resps_mutex;00514 00515         <span class="comment">// map for storing answers given to requests that have arrived. answers time out a while after</span>00516         <span class="comment">// the last time they were needed for a retransmit.</span>00517         <span class="comment">// map: &lt;request id ---&gt; answer buffer*&gt;</span>00518         <span class="comment">//   buffer_c.code holds the time (seconds part of get_time()) of the last transmission of this</span>00519         <span class="comment">//   answer. buffer_c.id holds the id of the request (same as the map "int" field)</span>00520         <span class="comment">//map&lt;int, buffer_c*&gt;  answs;</span>00521         <span class="comment">/*</span>00522 <span class="comment"></span>00523 <span class="comment">                trying again...</span>00524 <span class="comment"></span>00525 <span class="comment">                if entry not allocated: then it should be a new request.</span>00526 <span class="comment"></span>00527 <span class="comment">                if entry allocated: </span>00528 <span class="comment">                        WARNING: HACK</span>00529 <span class="comment">                        .code of entry is the TIME of last send (same as before)</span>00530 <span class="comment">                        .id : NOW means : 0 (RESPONSE WAITING CODE) if no answer given yet</span>00531 <span class="comment">                                          1 (RESPONSE ANSWERED CODE) if no answer given yet</span>00532 <span class="comment">                        </span>00533 <span class="comment">                                answer given. answer buffer.id holds id of request, .code the time</span>00534 <span class="comment">                (same as before)</span>00535 <span class="comment"></span>00536 <span class="comment">        */</span>00537         std::map&lt;int, buffer_c&gt;  answs;00538 00539         <span class="comment">//lock for accessing the answs map</span>00540         mutex_c         answs_mutex;00541 00542         <span class="comment">//atomic counter for counting pending requests. the shutdown procedure of</span>00543         <span class="comment">// the station will signal through the boolean condition that all requests</span>00544         <span class="comment">// should give up and then join with them as they decrement the pending</span>00545         <span class="comment">// counter.</span>00546         <span class="keyword">volatile</span> <span class="keywordtype">bool</span>                           stop_requests;00547         atomic_counter_c                pending_reqs;00548 00549         <span class="comment">// ---- channels ----</span>00550 00551         <span class="comment">//TCP master mode?</span>00552         <span class="keywordtype">bool</span> is_tcp_master;00553 00554         <span class="comment">//TCP listen port (managed outside the station)</span>00555         <span class="keywordtype">int</span> tcp_listen_port;00556 00557         <span class="comment">//TCP remote listen port</span>00558         <span class="keywordtype">int</span> tcp_remote_listen_port;00559 00560         <span class="comment">//channel tag (client-id for server)</span>00561         <span class="keywordtype">int</span> channel_tag;00562 00563         <span class="comment">//channel id generator</span>00564         atomic_counter_c channel_id_gen;00565         00566         <span class="comment">//TCP channels. map of POINTER to channel objects -- we can't take pointers</span>00567         <span class="comment">// of stuff inside an STL container, because STL moves things around!</span>00568         std::map&lt;int, channel_c*&gt;  channels;00569 00570         <span class="comment">//for every int--&gt;channel there is a single int--&gt;thread object here</span>00571         <span class="comment">// use the lock below to access this map too.</span>00572         <span class="comment">//map&lt;int, thread_c&lt;station_c&gt; &gt; channel_threads;</span>00573         <span class="comment">// troquei - threads n鉶 s鉶 joinable, elas apenas v鉶 embora.</span>00574         <span class="comment">// para saber se todas se foram, verifica-se o map channels tendo size == 0, porque</span>00575         <span class="comment">// a ultima coisa que a channel thread faz 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -