Web Hosting Tomcat, Java, JSP, Servlets, J2EE, PHP, MySQL

Cheap web hosting provider

31
Oct

Black Art of Java Game Programming by Joel

Black Art of Java Game Programming by Joel Fan Sams, Macmillan Computer Publishing ISBN: 1571690433 Pub Date: 11/01/96 Previous Table of Contents Next Command Parsing Here is a list of the commands this client must be able to understand (coincidentally, this is the same as the list of commands the server is able to send): list||name1&name2&name3 . This is a command that tells the client who is currently logged into the chat room. When we receive such a command, we must clear the List L and fill it with the new list of names. However, because List.clear() is broken in the Java language itself, we have to get around it by removing L from p2, reinstantiating it, and then adding it back to p2. This is a relatively timeconsuming process (compared to clearing the List), but it isn t too bad. Sun should have it fixed by the time you read this. logout||Name has left the room . This signifies that Name has left the chat room. The applet then removes his or her name from the List. Unfortunately, the delItem() method is also broken, so you will have to wait until this is fixed before this feature of our applet will work properly. login||Name||Name has entered the room . Signifies that Name has entered the chat room. Notice that in this and the command above, it is the server that determines what message to display, and that the client must obey blindly. If the command was not one of the ones listed above, we assume it is a message command of the form type||message . Currently, we ignore the type and just display the message. However, a neat extension of this applet would display different types of messages in different styles. See the Suggestion Box for more. Server Input Here is the code that handles input from the server in one big loop: while (sock != null && dis != null && kicker != null) { try { String str = dis.readLine(); System.out.println(”Got: “+str); if(str != null) if(str.indexOf(”||”) != -1) { StringTokenizer st = new StringTokenizer(str,”||”); String cmd = st.nextToken(); String val = st.nextToken(); if(cmd.equals(”list”)) { p2.remove(L); L = new List();

Hint: If you are looking for very good and affordable webspace to host and run your j2ee hosting application check Virtualwebstudio j2ee web hosting services

Comments are closed.

Home | About Us | Compare Plans | Standard Hosting | Business Hosting | Java Tomcat Hosting | Support | FAQ | Order Now!

Powered by Omnicus java hosting services. All rights reserved.
Entries (RSS) and Comments (RSS).