Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
NetPeer.h
Go to the documentation of this file.
1
/* Project nGenEx
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: NetEx.lib
6
FILE: NetPeer.h
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
One side of a UDP net link connection
13
*/
14
15
16
#ifndef NetPeer_h
17
#define NetPeer_h
18
19
#include <windows.h>
20
#include "
NetAddr.h
"
21
#include "
List.h
"
22
#include "
ThreadSync.h
"
23
24
// +-------------------------------------------------------------------+
25
26
class
NetGram
;
27
class
NetMsg
;
28
29
// +-------------------------------------------------------------------+
30
31
class
NetPeer
32
{
33
public
:
34
static
const
char
*
TYPENAME
() {
return
"NetPeer"
; }
35
36
enum
STATUS
{
OK
,
SEND_OVERFLOW
,
RECV_OVERFLOW
};
37
38
NetPeer
(
const
NetAddr
& addr, DWORD
id
);
39
~NetPeer
();
40
41
int
operator ==
(
const
NetPeer
& p)
const
{
return
netid == p.netid; }
42
43
bool
SendMessage
(
NetMsg
* msg);
44
NetMsg
*
GetMessage
();
45
46
NetGram
*
ComposeGram
();
47
bool
ReceiveGram
(
NetGram
* g,
List<NetMsg>
* q=0);
48
49
const
NetAddr
&
Address
()
const
{
return
addr; }
50
DWORD
NetID
()
const
{
return
netid; }
51
DWORD
Sequence
()
const
{
return
sequence; }
52
53
int
GetMaxPPS
()
const
{
return
pps; }
54
void
SetMaxPPS
(
int
p) { pps = p; }
55
int
GetMaxBPS
()
const
{
return
bps; }
56
void
SetMaxBPS
(
int
b) { bps = b; }
57
int
GetMaxQSize
()
const
{
return
max_qsize; }
58
void
SetMaxQSize
(
int
q) { max_qsize = q; }
59
60
DWORD
GetChunkSize
()
const
{
return
chunk_size; }
61
void
SetChunkSize
(DWORD s) { chunk_size = s; }
62
63
DWORD
LastReceiveTime
()
const
{
return
last_recv_time; }
64
void
SetLastReceiveTime
(DWORD t) { last_recv_time = t; }
65
66
private
:
67
bool
OKtoSend()
const
;
68
void
CheckMultiRecv(
List<NetMsg>
* q);
69
70
NetAddr
addr;
// remote network address
71
DWORD sequence;
// highest packet id received
72
DWORD netid;
// unique id for this peer
73
int
pps;
// max packets per second
74
int
bps;
// max bits per second
75
int
max_qsize;
// max bytes in either queue
76
int
status;
// ok or error code
77
DWORD chunk_size;
// size of multipart message chunk
78
79
enum
HIST { HIST_SIZE=8 };
80
81
DWORD last_recv_time;
// time of last received packet
82
DWORD hist_time[HIST_SIZE];
// history for pps check
83
DWORD hist_size[HIST_SIZE];
// history for bps check
84
int
hist_indx;
// index into history
85
86
int
send_size;
// total bytes in send list
87
int
recv_size;
// total bytes in recv list
88
List<NetMsg>
send_list;
// queue of messages waiting to be sent
89
List<NetMsg>
recv_list;
// queue of messages waiting to be read
90
91
List<NetMsg>
multi_send_list;
92
List<NetMsg>
multi_recv_list;
93
94
ThreadSync
sync;
95
};
96
97
98
#endif NetPeer_h
NetEx
NetPeer.h
Generated on Thu May 31 2012 16:30:50 for Starshatter_Open by
1.8.1