[Tux4kids-commits] r1062 - tuxmath/branches/lan/server
akash gangil
gangil-guest at alioth.debian.org
Wed Jun 17 11:54:15 UTC 2009
Author: gangil-guest
Date: 2009-06-17 11:54:15 +0000 (Wed, 17 Jun 2009)
New Revision: 1062
Added:
tuxmath/branches/lan/server/testclient.h
Modified:
tuxmath/branches/lan/server/Makefile.am
tuxmath/branches/lan/server/testclient.c
Log:
setting up switch in client as well
Modified: tuxmath/branches/lan/server/Makefile.am
===================================================================
--- tuxmath/branches/lan/server/Makefile.am 2009-06-17 03:24:20 UTC (rev 1061)
+++ tuxmath/branches/lan/server/Makefile.am 2009-06-17 11:54:15 UTC (rev 1062)
@@ -6,5 +6,5 @@
tuxmathserver_SOURCES = server.c mathcards.c
tuxmathtestclient_SOURCES = testclient.c
-EXTRA_DIST = mathcards.h server.h
-
+EXTRA_DIST = mathcards.h server.h testclient.h
+
Modified: tuxmath/branches/lan/server/testclient.c
===================================================================
--- tuxmath/branches/lan/server/testclient.c 2009-06-17 03:24:20 UTC (rev 1061)
+++ tuxmath/branches/lan/server/testclient.c 2009-06-17 11:54:15 UTC (rev 1062)
@@ -23,8 +23,8 @@
#include "SDL_net.h"
#include "transtruct.h"
#include "mathcards.h"
+#include "testclient.h"
-
TCPsocket sd; /* Socket descriptor */
SDLNet_SocketSet set;
@@ -40,6 +40,7 @@
char buffer[512]; // for command-line input
char buf[512]; // for network messages from server
int x, i = 0;
+ int command_type;
/* Simple parameter checking */
if (argc < 3)
@@ -138,13 +139,25 @@
printf("buf is %s\n", buf);
printf("command is %s\n", command);
-
+ command_type=-1;
/* Now we process the buffer according to the command: */
if(strcmp(command, "SEND_QUESTION") == 0)
{
- Make_Flashcard(buf, &flash); /* function call to parse buffer into MC_FlashCard */
+ command_type=SEND_QUESTION; //from the enum in testclient.h
}
- }
+
+ switch(command_type)
+ {
+ case SEND_QUESTION:
+ {
+ if(!Make_Flashcard(buf, &flash)) /* function call to parse buffer into MC_FlashCard */
+ printf("Unable to parse buffer into FlashCard\n");
+ break;
+ }
+ default :
+ break;
+ }
+ }
}
}
printf("No active sockets within timeout interval\n");
@@ -162,7 +175,7 @@
{
int i, j, tab = 0, s = 0;
char formula[MC_FORMULA_LEN];
- sscanf (buf,"%*s %d %d %d %s",
+ sscanf (buf,"%*s%d%d%d%s",
&fc->question_id,
&fc->difficulty,
&fc->answer,
Added: tuxmath/branches/lan/server/testclient.h
===================================================================
--- tuxmath/branches/lan/server/testclient.h (rev 0)
+++ tuxmath/branches/lan/server/testclient.h 2009-06-17 11:54:15 UTC (rev 1062)
@@ -0,0 +1,25 @@
+/*
+
+ testclient.h
+
+ Description: As of now it conatinsthe enum, which identifies
+ the network commands , as they are added(WORK IN PROGRESS).
+
+ Author: David Bruce ,Akash Gangil and the TuxMath team, (C) 2009
+
+ Copyright: See COPYING file that comes with this distribution (briefly, GNU GPL version 2 or later)
+
+*/
+
+
+
+
+#ifndef TESTCLIENT_H
+#define TESTCLIENT_H
+
+
+enum {
+ SEND_QUESTION
+};
+
+#endif
More information about the Tux4kids-commits
mailing list