Pass Webserver instance to function

35 views
Skip to first unread message

Thomas Matthis

unread,
Oct 19, 2012, 6:10:11 AM10/19/12
to webd...@googlegroups.com
I'm implementing some code to serve a list of files on the SD card on a web page.  I'd like to pass the Webserver instance from my webduino registered command to a subroutine.  I've tried eveery way I can think of to do this and can't figure it out.
 
So I have a default command like this
 
void helloCmd(WebServer &server, WebServer::ConnectionType type, char *, bool)  // this command is registered with the webserver
{
    server.print("Stuff to serve")
    listFiles(server, other parms);
}
void listFiles(Webserver& server, other parms)  // this command is not registered with the webserver
{
  Code to read SD card;
  server.print(filename);
  server.print(filesize);
  server.print(filesize);
  etc.....
}
 
How can I pass the current webserver instance to a subroutine, or how can I pass a pointer to the current instance.  I've thought about modding websever.h to make m_client public and pass server.client, but I'm not sure that would work either.
 
Being able to pass the webserver instance would make code for my various pages less redundant and more effecient.  Anyone have any ideas how to do this?
Reply all
Reply to author
Forward
0 new messages