Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

uniclientconn.h

00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Tunnel Vision Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * Manages a connection between the UniConf client and daemon.
00006  */
00007 #ifndef __UNICONFCONN_H
00008 #define __UNICONFCONN_H
00009 
00010 #include "uniconfkey.h"
00011 #include "uniconfgen.h"
00012 #include "wvstreamclone.h"
00013 #include "wvistreamlist.h"
00014 #include "wvbuf.h"
00015 #include "wvlog.h"
00016 
00017 #define DEFAULT_UNICONF_DAEMON_TCP_PORT 4111
00018 #define DEFAULT_UNICONF_DAEMON_SSL_PORT 4112
00019 
00026 class UniClientConn : public WvStreamClone
00027 {
00028     WvDynBuf msgbuf;
00029 
00030 protected:
00031     WvLog log;
00032     bool closed;
00033     
00034 public:
00035     WvConstStringBuffer payloadbuf; 
00036     enum Command
00037     {
00038         NONE = -2, 
00039         INVALID = -1, 
00041         // requests
00042         REQ_NOOP, 
00043         REQ_GET, 
00044         REQ_SET, 
00045         REQ_REMOVE, 
00046         REQ_SUBTREE, 
00047         REQ_HASCHILDREN, 
00048         REQ_QUIT, 
00049         REQ_HELP, 
00051         // command completion replies
00052         REPLY_OK, 
00053         REPLY_FAIL, 
00054         REPLY_CHILD, 
00055         REPLY_ONEVAL, 
00057         // partial replies
00058         PART_VALUE, 
00059         PART_TEXT, 
00061         // events
00062         EVENT_HELLO, 
00063         EVENT_NOTICE, 
00064     };
00065     static const int NUM_COMMANDS = EVENT_NOTICE + 1;
00066     struct CommandInfo
00067     {
00068         const char *name;
00069         const char *description;
00070     };
00071     static const CommandInfo cmdinfos[NUM_COMMANDS];
00072 
00074     UniClientConn(IWvStream *_s, WvStringParm dst = WvString::null);
00075     virtual ~UniClientConn();
00076 
00077     virtual void close();
00078 
00084     Command readcmd();
00085 
00090     WvString readarg();
00091 
00097     void writecmd(Command command, WvStringParm payload = WvString::null);
00098 
00103     void writeok(WvStringParm payload = "");
00104 
00109     void writefail(WvStringParm payload = "");
00110 
00116     void writevalue(const UniConfKey &key, WvStringParm value);
00117 
00123     void writeonevalue(const UniConfKey &key, WvStringParm value);
00124 
00129     void writetext(WvStringParm text);
00130 
00131 private:
00133     WvString readmsg();
00134 
00136     void writemsg(WvStringParm message);
00137 };
00138 
00139 #endif // __UNICONFCONN_H

Generated on Tue Jul 12 02:59:27 2005 for WvStreams by  doxygen 1.4.0