Logo Search packages:      
Sourcecode: earth3d version File versions  Download package

void ConnectNetworkService::run (  )  [virtual]

Wait and process responses for the given time.

Definition at line 80 of file connectNetworkService.cpp.

References parseDocument(), parts, sender, sflList, and sl.

                                {
  // now we are connected to the server

  while(1) {
//     printf("start readParts\n");
    int countParts = sl.readParts(sender, 255, parts, 100);
    if (countParts==0) break;
//     printf("countParts=%i\n", countParts);
    printf("received...\n");
    char line[1024];
    strncpy(line, parts[0].content, min(parts[0].size, 1023));
    line[min(parts[0].size,1023)]=0;
    printf("------------------------------------------------------------\n"
         "Sender: %s\n"
         "XML: %s\n"
         "------------------------------------------------------------\n", sender, line);
    // send to all listeners
    std::vector<ServiceFoundListener *>::iterator it = sflList.begin();
    while(it!=sflList.end()) {
      char *doc = new char[parts[0].size+1];
      memcpy(doc, parts[0].content, parts[0].size);
      doc[parts[0].size]=0;
      ((ServiceFoundListener *)(*it))->serviceFound(doc, sender);
      delete(doc);

      it++;
    }

    // BEGIN Parse the content
    parseDocument(countParts, parts, sender);
    // END Parse the content

    sl.freeParts(parts, countParts);
  }
}


Generated by  Doxygen 1.6.0   Back to index