src/network/core/tcp.h
changeset 5902 a9508c166390
parent 5872 63eafeb3f393
child 6121 2aae24b0881f
equal deleted inserted replaced
5901:ab59510b0c9c 5902:a9508c166390
    82 } ClientStatus;
    82 } ClientStatus;
    83 
    83 
    84 /** Base socket handler for all TCP sockets */
    84 /** Base socket handler for all TCP sockets */
    85 class NetworkTCPSocketHandler : public NetworkSocketHandler {
    85 class NetworkTCPSocketHandler : public NetworkSocketHandler {
    86 /* TODO: rewrite into a proper class */
    86 /* TODO: rewrite into a proper class */
       
    87 private:
       
    88 	Packet *packet_queue;     ///< Packets that are awaiting delivery
       
    89 	Packet *packet_recv;      ///< Partially received packet
    87 public:
    90 public:
    88 	uint16 index;             ///< Client index
    91 	uint16 index;             ///< Client index
    89 	uint32 last_frame;        ///< Last frame we have executed
    92 	uint32 last_frame;        ///< Last frame we have executed
    90 	uint32 last_frame_server; ///< Last frame the server has executed
    93 	uint32 last_frame_server; ///< Last frame the server has executed
    91 	byte lag_test;            ///< Byte used for lag-testing the client
    94 	byte lag_test;            ///< Byte used for lag-testing the client
    92 
    95 
    93 	ClientStatus status;      ///< Status of this client
    96 	ClientStatus status;      ///< Status of this client
    94 	bool writable;            ///< Can we write to this socket?
    97 	bool writable;            ///< Can we write to this socket?
    95 
    98 
    96 	Packet *packet_queue;     ///< Packets that are awaiting delivery
       
    97 	Packet *packet_recv;      ///< Partially received packet
       
    98 
       
    99 	CommandPacket *command_queue; ///< The command-queue awaiting delivery
    99 	CommandPacket *command_queue; ///< The command-queue awaiting delivery
   100 
   100 
   101 	NetworkRecvStatus CloseConnection();
   101 	NetworkRecvStatus CloseConnection();
   102 	void Initialize();
   102 	void Initialize();
       
   103 	void Destroy();
       
   104 
       
   105 	void Send_Packet(Packet *packet);
       
   106 	bool Send_Packets();
       
   107 	bool IsPacketQueueEmpty();
       
   108 
       
   109 	Packet *Recv_Packet(NetworkRecvStatus *status);
   103 };
   110 };
   104 
       
   105 
       
   106 
       
   107 void NetworkSend_Packet(Packet *packet, NetworkTCPSocketHandler *cs);
       
   108 Packet *NetworkRecv_Packet(NetworkTCPSocketHandler *cs, NetworkRecvStatus *status);
       
   109 bool NetworkSend_Packets(NetworkTCPSocketHandler *cs);
       
   110 
   111 
   111 #endif /* ENABLE_NETWORK */
   112 #endif /* ENABLE_NETWORK */
   112 
   113 
   113 #endif /* NETWORK_CORE_TCP_H */
   114 #endif /* NETWORK_CORE_TCP_H */