MiMic for MbedCompiler用のhttpd擬似コード

Mbedでさくっと簡単Httpd!はこんなカンジに使えるといいですね。

--------

ModRemoteMcu   mod_remote_mcu;
ModMiMicConfig mod_mimic_config;

class Httpd:MiMicHttpd
{
  void onGetRequest(HttpdConnection)
  {
    if(mod_remote_mcu.canHandle(connection)){
      mod_remote_mcu.execute();
    }else if(mod_mimic_config.canHandle(connection))
    {
      mod_mimic_config.execute();
    }else if(connection.isShortURL()){
      ShortURL* u=connection.getShortURL();
      if(u.match("/")){
        connection->writeHeader();
        connection->writeBody();
      }
    }
    connection->writeHeader();
    connection->writeBody();
    connection->Close();
  }
}

void main(void)
{
  config=loadFlashSetting();
  MiMicNet net=new MiMicNet(config);
  httpd=new Httpd(net);
  net.loop();
}

Telnetはこんなカンジで使えるとイイナー。

--------

class Telnet:MiMicTelnet
{
  class Connection
  {
    void send
    void recv
    vid close
  }
  void onConnect(connection)
  {
    recv()
    send()
    close()
  }
}

void main(void)
{
  config=loadFlashSetting();
  MiMicNet net=new MiMicNet(config);
  telnet=new Telnet(net);
  net.loop();
}

Comments are closed, but trackbacks and pingbacks are open.