]> git.cworth.org Git - ttt/blobdiff - src/ttt-server.c
2005-12-02 Richard D. Worth <richard@theworths.org>
[ttt] / src / ttt-server.c
index 60276d39ccf691bed7b86e90822e02d3fb90abd7..23fd138cb375d24f611eb85b45bc7d0460267f1e 100644 (file)
@@ -74,7 +74,7 @@ ttt_server_register_client (ttt_server_t *server, ttt_client_t *client)
        }
     }
 
-    printf ("Client %s has joined.\n", name);
+    printf ("Client %s has joined.\r\n", name);
 
     server->num_clients++;
 
@@ -110,7 +110,7 @@ ttt_server_unregister_client (ttt_server_t *server, ttt_client_t *client)
 
     assert (i < server->num_clients);
 
-    printf ("Client %s has left.\n", ttt_client_get_name (client));
+    printf ("Client %s has left.\r\n", ttt_client_get_name (client));
 
     memmove (&server->clients[i], &server->clients[i+1],
             (server->num_clients - i - 1) * sizeof (ttt_client_t *));
@@ -146,9 +146,12 @@ ttt_server_who (ttt_server_t *server)
     xasprintf (&response, "WHO");
 
     for (i = 0; i < server->num_clients; i++)
-       xasprintf (&response, "%s %s", response, ttt_client_get_name(server->clients[i]));
+       xasprintf (&response, "%s %s %d",
+                  response,
+                  ttt_client_get_name (server->clients[i]),
+                  ttt_client_get_num_wins (server->clients[i]));
 
-    xasprintf (&response, "%s\n", response);
+    xasprintf (&response, "%s\r\n", response);
 
     pthread_mutex_unlock (&server->mutex);
 
@@ -170,26 +173,18 @@ ttt_server_get_port (ttt_server_t *server)
 }
 
 static const char *WELCOME_MESSAGE = 
-"Welcome to ttt-server. So far, this program is still a demonstration\n"
-"TCP/IP server, acting something like a rather braindead chat server.\n"
-"The server is currently listening on:\n"
-"\n    %s:%s\n"
-"\nTo test this, simply connect one or more clients to that host and port.\n"
-"For example:\n"
-"\n    telnet %s %s\n"
-"\nOnce you have connected a client, the server will send each line of text\n"
-"it receives to all connected clients. The server reports client joins and\n"
-"departures on stdout.\n"
-"\nNote that to terminate the telnet client you type Control-], then\n"
-"<Enter>, then \"close\" (and <Enter>) at the \"telnet> \" prompt.\n"
-"\nHave fun!\n"
-"-Carl\n"
-"\nPS. At this point we're ready to leave the demonstration phase and to\n"
-"begin implementing TTTP (tic-tac-toe protocol) as well as fixing the\n"
-"protocol specifcation. We don't need a custom client to move forward on\n"
-"the server (that is one of the ideas behind using a telnet-compatible\n"
-"protocol), but a custom client would still be a fine project for a\n"
-"motivated beginning programmer.\n\n";
+"Welcome to ttt-server. The server is currently listening on:\r\n"
+"\r\n"
+"      %s:%s\r\n"
+"\r\n"
+"To test this, simply connect one or more clients to that host and port.\r\n"
+"For example:\r\n"
+"\r\n"
+"      telnet %s %s\r\n"
+"\r\n"
+"The TTTP (tic-tac-toe protocol) has been partially implemented.\r\n"
+"The following commands should work: HELO, HELP, MESSAGE, VERSION, QUIT, WHO.\r\n"
+"\r\n";
 
 static void
 _ttt_server_accept (void *closure, int client_socket)