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 commands.property), 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?
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 com.lyrisoft.chat.client.Client. 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()@com.lyrisoft.chat.server.remote.ChatClient
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 com.lyrisoft.chat.server.local.comand and an entry into commandProcessors.properties (found
in the resources directory of the client). Now the client should accept your command.
At least, add some methods to Client.java, ChatGUI.java, if needed. See e.g. AckSignOn.java in package com.lyrisoft.chat.server.local.
Perhaps this answers your questions...
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.