Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
Network.h
Go to the documentation of this file.
1#ifndef ULT_NETWORK_NETWORK_H_INCLUDED
2#define ULT_NETWORK_NETWORK_H_INCLUDED
3
6
7namespace Ult
8{
9
13
19{
20public:
26 Network(int maxConnections);
30 ~Network();
31
37 bool Host(int port, int numPending);
42 NetResult Connect(const char* ipAddr, int port);
43
48 void Disconnect();
53 void DisconnectClient(int index);
54
58 NetResult Send(Packet& packet);
62 NetResult Send(Packet& packet, int sendTo);
63
67 void Process();
68
73 void SetCallbackFunction(NetCallback funcPtr) { mCallback = funcPtr; }
75 bool IsConnected() const { return mIsConnected; }
77 int GetMaxConnections() const { return mMaxConnections; }
79 int GetTotalConnections() const { return mTotalUsers; }
81 NetType GetNetworkType() const { return mNetworkType; }
82
83private:
84 bool mIsConnected;
85 NetType mNetworkType;
86 Socket mConnection;
87 Socket* mUsers;
88 int mTotalUsers;
89 int mMaxConnections;
90 NetCallback mCallback;
91
92 bool AcceptConnection();
93 NetResult SendPacket(Packet& packet);
94 NetResult SendPacket(Packet& packet, int sendTo);
95};
96
97} // namespace Ult
98
99#endif // ULT_NETWORK_NETWORK_H_INCLUDED
100
void DisconnectClient(int index)
Definition Network.cpp:70
void Process()
Definition Network.cpp:103
Network(int maxConnections)
Definition Network.cpp:6
void Disconnect()
Definition Network.cpp:47
void SetCallbackFunction(NetCallback funcPtr)
Definition Network.h:73
NetType GetNetworkType() const
Definition Network.h:81
int GetMaxConnections() const
Definition Network.h:77
int GetTotalConnections() const
Definition Network.h:79
~Network()
Definition Network.cpp:20
NetResult Send(Packet &packet)
Definition Network.cpp:86
bool Host(int port, int numPending)
Definition Network.cpp:28
bool IsConnected() const
Definition Network.h:75
NetResult Connect(const char *ipAddr, int port)
Definition Network.cpp:37
Definition Packet.h:16
Definition Socket.h:16
void(* NetCallback)(int u, int y, char *d, int s)
Definition Types.h:77
NetType
Definition Types.h:50
NetResult
Definition Types.h:58
Definition Archive.h:13