From cbd22101bcff041e598aba668412d0a4232b58e3 Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 27 Jun 2007 17:05:05 +0000 Subject: git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@217 4f64403b-2f21-0410-a795-97e2b3489a10 --- MySpace/NetMessage.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 MySpace/NetMessage.h (limited to 'MySpace/NetMessage.h') diff --git a/MySpace/NetMessage.h b/MySpace/NetMessage.h new file mode 100644 index 0000000..8261302 --- /dev/null +++ b/MySpace/NetMessage.h @@ -0,0 +1,58 @@ +#ifndef _NET_MESSAGE_INC +#define _NET_MESSAGE_INC + +#include "collection.h" + +class NMString { +public: + NMString(); + NMString(const NMString &other); + NMString(char *t); + virtual ~NMString(); + + const bool operator<(const NMString &other) const; + const bool operator==(const NMString &other) const; + NMString &operator=(const NMString &other); + + char *text; +}; + +class NetMessage: public Map { +public: + NetMessage(); + virtual ~NetMessage(); + + int parse(char *data, int size); + + bool get_string(char *key, char *buff, int buffsize); + bool get_data(char *key, char *buff, int *size); + int get_int(char *key); + + static char *unescape_inplace(char *val); +}; + +class KeyValue: public Pair { +public: + KeyValue(const NMString &k, const NMString &v): Pair(k, v) {} + KeyValue &operator=(const KeyValue &other) { + first = other.first; + second = other.second; + return *this; + } +}; + +class ClientNetMessage: public LinkedList< KeyValue > { +public: + ClientNetMessage(); + virtual ~ClientNetMessage(); + + int ClientNetMessage::make_packet(char *buff, int size); + + void add_string(char *key, char *buff); + void add_data(char *key, char *buff, int size); + void add_int(char *key, int i); + + static char *escape(char *val); +}; + +#endif -- cgit v1.2.3