00001 #ifndef SERVER_CONNECTION_HH_ 00002 # define SERVER_CONNECTION_HH_ 00003 00004 # include <winsock2.h> 00005 # include <windows.h> 00006 # include <string> 00007 # include <sstream> 00008 # include <iostream> 00009 00010 # include "rxsocket.hh" 00011 # include "incoming-packet.hh" 00012 # include "outgoing-packet.hh" 00013 # include "cronous-env.hh" 00014 00015 namespace connection 00016 { 00017 class ServerConnection : protected rxsocket::RxTCPClient 00018 { 00019 public: 00020 ServerConnection(const std::string &host, u_short port); 00021 00022 void print(std::ostream &os) const; 00023 void fill_packet(packets::IncomingPacket *ip); 00024 void push_packet(packets::OutgoingPacket *op); 00025 int get_op(); 00026 int data_available(); 00027 void start_connection(); 00028 00029 ServerConnection &operator <<(packets::OutgoingPacket *op); 00030 static ServerConnection &get_instance(); 00031 00032 protected: 00033 packets::IncomingPacket *_current_packet; 00034 00035 void fill_packet_now(); 00036 virtual void event_connect(); 00037 virtual void event_close(); 00038 virtual void can_read(); 00039 }; 00040 00041 std::ostream &operator <<(std::ostream &os, const ServerConnection &sc); 00042 } 00043 00044 #endif