From b7a993e0d6aebb98c06e88eb9ca0aaa3674dfe78 Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 2 May 2005 19:47:43 +0000 Subject: Fixed overlapping cpr numbers on the server (now it saves one cpr pr. connection, and ignores any changes sent) --- src/miav.cc | 15 +++++++-------- src/server.cc | 19 +++++++++++++++---- 2 files changed, 22 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/miav.cc b/src/miav.cc index ef2a369..2316413 100644 --- a/src/miav.cc +++ b/src/miav.cc @@ -26,6 +26,10 @@ */ /* * $Log$ + * Revision 1.6 2005/05/02 19:47:43 deva + * Fixed overlapping cpr numbers on the server (now it saves one cpr pr. + * connection, and ignores any changes sent) + * * Revision 1.5 2005/05/01 09:56:26 deva * Added Id and Log tags to all files * @@ -71,19 +75,14 @@ int grab(int argc, char *argv[]) { * This function starts the MIaV server. */ int server(int argc, char *argv[]) { + int port = config->readInt("server_port"); pid_t childpid; // variable to store the child's pid signal(SIGCLD, SIG_IGN); // Ved SIGCHILD til IGNORE maa wait/waitpid ikke kaldes // (ellers kommer der kernel-brok) - if(argc < 1) { - printf("Usage: miav server [port]\n"); - printf("[port] Is the port number the server will be listening to.\n"); - return 1; - } - - printf("Listening on port %d\n",atoi(argv[0])); - Socket *socket = new Socket(atoi(argv[0])); + printf("Listening on port %d\n", port); + Socket *socket = new Socket(port); while(1) { Socket *csocket = new Socket(socket->slisten()); diff --git a/src/server.cc b/src/server.cc index 27b6848..c8a359e 100644 --- a/src/server.cc +++ b/src/server.cc @@ -26,6 +26,10 @@ */ /* * $Log$ + * Revision 1.10 2005/05/02 19:47:43 deva + * Fixed overlapping cpr numbers on the server (now it saves one cpr pr. + * connection, and ignores any changes sent) + * * Revision 1.9 2005/05/02 18:46:15 deva * Files are now saved in a custom folder (defined in miav.conf) * @@ -246,6 +250,8 @@ MovEncoder *newMovEncoder(char* cpr) void newConnection(Socket *socket) { + char cpr[256]; + bool hasCpr = false; ServerStatus status; n_savestate savestate = LATER; @@ -267,25 +273,30 @@ void newConnection(Socket *socket) break; } + if(!hasCpr) { + sprintf(cpr, h.header.h_data.cpr); + hasCpr = true; + } + printf("Read: %d bytes ", ret); printf("\ttyp: %d ", h.header_type); - printf("\tcpr: %s ", h.header.h_data.cpr); + printf("\tcpr: %s ", cpr); printf("\tfrz: %d ", h.header.h_data.freeze); printf("\tsht: %d ", h.header.h_data.snapshot); printf("\tsave: %d\n", h.header.h_data.savestate); if(h.header.h_data.snapshot) { if(freeze_frame) { - saveFrameAsImage(h.header.h_data.cpr, freeze_frame); + saveFrameAsImage(cpr, freeze_frame); delete freeze_frame; freeze_frame = NULL; } else { - saveFrameAsImage(h.header.h_data.cpr, frame); + saveFrameAsImage(cpr, frame); } } if(h.header.h_data.record) { - if(!enc) enc = newMovEncoder(h.header.h_data.cpr); + if(!enc) enc = newMovEncoder(cpr); enc->encode(frame); } -- cgit v1.2.3