Exemple #1
0
    void run() {

      // initialise the LCD and then the network

      initialiseLcd();
      initialiseNetwork();

      // do a DNS lookup for the server and read the index file

      lookupServerAddress();
      readPictureIndex();

      // give a small delay so that the user can see the startup info

      writeLine("Starting in 5 seconds");
      MillisecondTimer::delay(5000);

      // go into an infinite loop showing the pictures with a 10 second
      // delay between each one

      for(;;) {
        for(auto it=_pictureUriList.begin();it!=_pictureUriList.end();it++) {
          showPicture(*it);
          MillisecondTimer::delay(10000);
        }
      }
    }
Exemple #2
0
    void readPictureIndex() {

      writeLine("Connecting to server...");

      // create the connection

      MyTcpClientConnection *ptr;

      if(!_net->tcpConnect<MyTcpClientConnection>(_serverAddress,WEB_SERVER_PORT,ptr))
        error("Failed to connect to web server");

      {
        // manage the connection pointer in a scoped_ptr so it's automatically deleted (and closed)
        // when it goes out of scope

        scoped_ptr<MyTcpClientConnection> conn(ptr);
        HttpClient httpClient(*conn);

        // set the parameters for the HTTP GET

        httpClient.setUri(PICTURE_INDEX_URI);
        httpClient.setHost(WEB_SERVER);
        httpClient.setVersion(HttpVersion::HTTP_1_0);

        // send it

        writeLine("Sending request for index...");

        if(!httpClient.sendRequest())
          error("Failed to send the request to the server");

        // read the response lines up to max of 200 per line

        TcpTextLineReceiver lineReceiver(200);

        writeLine("Reading index...");
        _pictureUriList.clear();

        for(;;) {

          if(!lineReceiver.add(*conn))
            error("Failed to index data");

          if(lineReceiver.ready()) {

            if(!strcasecmp(lineReceiver.str().c_str(),"#end"))
              break;

            _pictureUriList.push_front(lineReceiver.str());
            lineReceiver.reset();
          }
        }
      }

      char buf[100];
      StringUtil::modp_uitoa10(_pictureUriList.size(),buf);
      strcat(buf," images indexed");
      writeLine(buf);
    }
inline void load(
    Archive & ar,
    STD::slist<U, Allocator> &t,
    const unsigned int file_version
){
    // retrieve number of elements
    t.clear();
    // retrieve number of elements
    unsigned int count;
    ar >> BOOST_SERIALIZATION_NVP(count);
    if(0 == count)
        return;

    boost::serialization::stl::stack_construct<Archive, U> u(ar);
    ar >> boost::serialization::make_nvp("item", u.reference());
    t.push_front(u.reference());
    BOOST_DEDUCED_TYPENAME BOOST_STD_EXTENSION_NAMESPACE::slist<U, Allocator>::iterator last;
    last = t.begin();
    while(--count > 0){
        boost::serialization::stl::stack_construct<Archive, U> u(ar);
        ar >> boost::serialization::make_nvp("item", u.reference());
        last = t.insert_after(last, u.reference());
    }
}