00001 #ifndef CHAT_HH_ 00002 # define CHAT_HH_ 00003 00004 # include "incoming-packet.hh" 00005 # include "packets_fwd.hh" 00006 00007 namespace infos 00008 { 00009 class CustomChat : public packets::IncomingPacket 00010 { 00011 public: 00012 CustomChat(int size); 00013 00014 int get_id(); 00015 std::string get_name(); 00016 std::string get_text(); 00017 }; 00018 00019 template <int OP, int SIZE> 00020 class Chat : public CustomChat 00021 { 00022 public: 00023 Chat(int size = SIZE) : CustomChat(size) 00024 { 00025 } 00026 00027 const static int op = OP; 00028 00029 void print_tag(std::ostream &os) const 00030 { 00031 os << "chat<" << OP << ">"; 00032 } 00033 00034 void print_data(std::ostream &os) const 00035 { 00036 const char *str = _data.c_str(); 00037 os 00038 << "id: " << *(short *)(str + 1) 00039 << ", name: " << str + 5 00040 << ", text: " << str + 20; 00041 } 00042 00043 void process(packets::PacketVisitor &ph) 00044 { 00045 ph(*this); 00046 } 00047 }; 00048 }; 00049 00050 #endif