1 /*
2 * Replica is published under the terms
3 * of the Apache Software License.
4 */
5 package replica.server.commands;
6
7 import replica.core.*;
8 import replica.core.ApplicationMessage;
9 import replica.server.ServerProcess;
10
11 /***
12 * This command simple sends a given string to the user.
13 *
14 * @author Pedro Costa
15 * @author Helder Silva
16 * @since 21/Jan/2004
17 */
18 public class PrintCommand extends ApplicationCommand {
19
20 public final static String NAME = "print";
21
22 /***
23 * Default constructor.
24 */
25 public PrintCommand() {
26 super();
27 }
28
29 /* (non-Javadoc)
30 * @see replica.server.commands.ServerCommand#execute(replica.core.ApplicationMessage)
31 */
32 protected Object execute(ApplicationMessage arg) {
33
34 ServerProcess serverProcess = getServerProcess(arg.getSessionID());
35
36 if( serverProcess != null ){
37 String msg = arg.getBody().toString().trim();
38
39 if(msg.startsWith(NAME + " "))
40 msg = msg.substring( (NAME+" ").length() ).trim();
41
42 serverProcess.sendResponse(msg);
43 }
44
45 // else that session id belongs to any other group member
46
47 return null;
48 }
49
50 }
This page was automatically generated by Maven