Programming question- adding command

  • Daniel Ross

    Daniel Ross - 2005-08-15

    I'm trying, as a programming exercise, to add a simple command /rolldice <#number of sides> <# of dice>. I want this to execute on the server side, to make absolutely sure it's fair.

    I thought I had successfully added it to server.remote (by adding a server.remote.command class and an entry in, but when I attempted to enter the command in a Tomcat client window I was told the command did not exist. I gather from the source code that only the client is being checked for this, but I don't fully understand how it works.

    My questions are:
    What goes on client-side before the command is sent to the server?
    If the command has to be programmed into the client, what is the point of server-side commands?
    What is the minimum I have to do to successfully use this command?

    • Daniel Tahin

      Daniel Tahin - 2005-08-18


      On the client side, if you types everything in a chatroom or a privatechatroom, it will be
      processed using the function inputEvent()@IChatClientInputReceiver interface. This is implemented by
      the class So process()@UserCommands is invoked, that try to determine
      the command using the first word in the string, and uses the correct command processor, located in
      You can add your own command here, by placing the name of the command into the userCommands.Properties file
      in the resources (or web/resources) directory of the client.
      You can add some functions to the ChatServerLocal, CommandMakerLocal, ICommands. (See the stats-command!)
      At this point you will be able to send a command to the server.

      Depending on what your command the clients sends back (after it was processed by the remote server), you have two
      way. If you send:
      a) some simple message without any command. In this case, call generalMessage()/generalError()
         from your server-side command, you have currently added. The client displays the messages without to modify anything, and the job is finished.

      b) a command. For this there are some changes needed on the server and the client side as well. On the server side you can add again your functions
         into ChatClient, CommandMakerRemote (located in the remote-server package) and perhaps the "acknowledgement-command" to ICommands. See the SayToUser-command
         On the client-side, first a "command-processor" into and an entry into (found
         in the resources directory of the client). Now the client should accept your command.
         At least, add some methods to,, if needed. See e.g. in package

      Perhaps this answers your questions...


Log in to post a comment.