本文整理汇总了C++中Daemon::closeConnection方法的典型用法代码示例。如果您正苦于以下问题:C++ Daemon::closeConnection方法的具体用法?C++ Daemon::closeConnection怎么用?C++ Daemon::closeConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Daemon
的用法示例。
在下文中一共展示了Daemon::closeConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
openni::Device &device = __device;
openni::VideoStream &depth = __depth, &color = __color;
openni::Status rc;
char *prefix = strrchr(argv[0], '/')+1;
char *cfgfile = new char[prefix-argv[0]+strlen(rgbdsend::config_file_name)+1];
strncpy(cfgfile, argv[0], prefix-argv[0]+1);
strcpy(cfgfile+(prefix-argv[0]), rgbdsend::config_file_name);
Config conf;
if(conf.read(cfgfile) != 1) {
printf("Config: Falling back to builtin presets.\n");
conf.setDefaults();
}
delete[] cfgfile;
CURL *curl = init_curl();
Daemon daemon;
daemon.init(conf.daemon_port, conf.daemon_timeout);
atexit(atexit_handler);
init_openni(&device, &depth, &color, conf);
int dw, dh, cw, ch;
int tmp1, tmp2;
if(!depth.getCropping(&tmp1, &tmp2, &dw, &dh)) {
dw = depth.getVideoMode().getResolutionX();
dh = depth.getVideoMode().getResolutionY();
}
if(!color.getCropping(&tmp1, &tmp2, &cw, &ch)) {
cw = color.getVideoMode().getResolutionX();
ch = color.getVideoMode().getResolutionY();
}
printf("Resolution:\nDepth: %dx%d @ %d fps\nColor: %dx%d @ %d fps\n",
dw, dh, depth.getVideoMode().getFps(),
cw, ch, color.getVideoMode().getFps());
std::queue<char *> onilist;
Command cmd;
while(1) {
timeval t;
t.tv_sec = conf.daemon_timeout;
t.tv_usec = 0;
fd_set fds;
FD_ZERO(&fds);
FD_SET(daemon.sock, &fds);
FD_SET(daemon.csock, &fds);
int in = select((daemon.csock > daemon.sock ? daemon.csock : daemon.sock)+1, &fds, 0, 0, &t);
if(FD_ISSET(daemon.sock, &fds))
daemon.acceptConnection();
if(FD_ISSET(daemon.csock, &fds)) {
char b[5];
int r = daemon.receiveCommand(&cmd);
if(r == 0) {
printf("Daemon Error: Could not receive command.\n");
daemon.closeConnection();
continue;
}
if(r == 2) // keep alive
continue;
if(strncmp(cmd.header, "capt", 4) == 0) {
printf("Received capture command.\n");
char *newfile = new char[rgbdsend::filename_bufsize];
if(record_oni(newfile, rgbdsend::filename_bufsize, depth, color, conf) == true) {
onilist.push(newfile);
} else {
delete[] newfile;
}
daemon.sendCommand("okay", 0, 0);
} else if(strncmp(cmd.header, "thmb", 4) == 0) {
printf("Received thumbnail command.\n");
unsigned char *thumbbuf = NULL;
long unsigned int size = 0;
capture_thumbnail(&thumbbuf, &size, color);
printf("Captured thumbnail. %ld bytes\n", size);
daemon.sendCommand("stmb", thumbbuf, size);
// delete[] thumbbuf; seems like libjpeg handles this. but I'm not sure.
} else if(strncmp(cmd.header, "quit", 4) == 0) {
daemon.closeConnection();
} else {
//.........这里部分代码省略.........