Logo
~Sockets~
~Examples~
~Contact~


AdminSocket Class Reference

#include <AdminSocket.h>

List of all members.


Public Member Functions

 AdminSocket (ISocketHandler &)
 ~AdminSocket ()
void Exec ()

Private Member Functions

 AdminSocket (const AdminSocket &s)
AdminSocketoperator= (const AdminSocket &)

Detailed Description

Definition at line 7 of file AdminSocket.h.


Constructor & Destructor Documentation

AdminSocket::AdminSocket ( ISocketHandler &   ) 

Definition at line 8 of file AdminSocket.cpp.

00009 :HttpdSocket(h)
00010 {
00011 }

AdminSocket::~AdminSocket (  ) 

Definition at line 14 of file AdminSocket.cpp.

00015 {
00016 }

AdminSocket::AdminSocket ( const AdminSocket s  )  [inline, private]

Definition at line 16 of file AdminSocket.h.

00016 : HttpdSocket(s) {} // copy constructor


Member Function Documentation

void AdminSocket::Exec (  ) 

Definition at line 19 of file AdminSocket.cpp.

References MHandler::AddService(), and MHandler::GetServices().

00020 {
00021         MHandler& h = static_cast<MHandler&>(Handler());
00022 
00023         // POST /add
00024         if (GetMethod() == "POST" && GetUri() == "/add")
00025         {
00026                 std::string local_port = GetForm() -> getvalue("port");
00027                 std::string remote_host = GetForm() -> getvalue("remote_host");
00028                 std::string remote_port = GetForm() -> getvalue("remote_port");
00029                 port_t port = atoi(local_port.c_str());
00030                 port_t rport = atoi(remote_port.c_str());
00031                 if (port && remote_host.size() && rport)
00032                 {
00033                         h.AddService(port, remote_host, rport);
00034                 }
00035         }
00036 
00037         // create page
00038         Send("<html><head><title>Services</title>");
00039         Send("<style>"
00040                 "td { background: #e0e0e0; padding-left: 5px; padding-right: 5px; }"
00041                 "th { background: #c0c0c0; padding-left: 5px; padding-right: 5px; }"
00042                 "</style>");
00043         Send("</head>");
00044         Send("<body>");
00045         Send("<h3>Service administration</h3>");
00046         
00047         Send("<table cellspacing='1'>");
00048         Send("<tr><th>Local port</th><th>Remote host</th><th>Remote port</th></tr>");
00049         MHandler::service_v& ref = h.GetServices();
00050         for (MHandler::service_v::iterator it = ref.begin(); it != ref.end(); it++)
00051         {
00052                 MHandler::SERVICE *p = *it;
00053                 Send("<tr>");
00054                 Send("<td align='right'>" + Utility::l2string(p -> port) + "</td>");
00055                 Send("<td align='center'>" + p -> remote_host + "</td>");
00056                 Send("<td align='right'>" + Utility::l2string(p -> remote_port) + "</td>");
00057                 Send("</tr>");
00058         }
00059         Send("</table>");
00060         // add service
00061         Send("<h3>Add service</h3>");
00062         Send("<form action='/add' method='POST'>");
00063         Send("Local port<br><input type='text' name='port'><br>");
00064         Send("Remote hostname<br><input type='text' name='remote_host'><br>");
00065         Send("Remote port<br><input type='text' name='remote_port'><br>");
00066         Send("<input type='submit' name='submit' value=' Add Service '>");
00067         Send("</form>");
00068         // end of document
00069         Send("</body></html>");
00070 
00071         //
00072         SetCloseAndDelete();
00073 }

AdminSocket& AdminSocket::operator= ( const AdminSocket  )  [inline, private]

Definition at line 17 of file AdminSocket.h.

00017 { return *this; } // assignment operator


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4