3 * Copyright (C) 2006 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package de.todesbaum.util.freenet.fcp2;
22 import java.io.IOException;
23 import java.io.Writer;
26 * Implementation of the <code>ClientHello</code> command. This command must
27 * be sent as the first command on a connection ({@link de.todesbaum.util.freenet.fcp2.Connection#connect()}
28 * takes care of that) and must not be sent afterwards.
30 * The node can answer with the following messages: <code>NodeHello</code>.
32 * @author David Roden <droden@gmail.com>
35 public class ClientHello extends Command {
37 /** The name of the client. */
38 protected String name;
40 /** The version of the FCP protocol the client expects. */
41 protected String expectedVersion = "2.0";
44 * Creates a new <code>ClientHello</code> command.
46 public ClientHello() {
47 super("ClientHello", "ClientHello-" + System.currentTimeMillis());
51 * Returns the value of the <code>ExpectedVersion</code> parameter of this
52 * command. At the moment this value is not used by the node but in the
53 * future this may be used to enforce certain node versions.
55 * @return The expected version
57 public String getExpectedVersion() {
58 return expectedVersion;
62 * Sets the value of the <code>ExpectedVersion</code> parameter of this
63 * command. At the moment this value is not used by the node but in the
64 * future this may be used to enforce certain node versions.
66 * @param expectedVersion
67 * The expected version
69 public void setExpectedVersion(String expectedVersion) {
70 this.expectedVersion = expectedVersion;
74 * Returns the name of the client that is connecting.
76 * @return The name of the client
78 public String getName() {
83 * Sets the name of the client that is connecting.
86 * The name of the client
88 public void setName(String name) {
96 protected void write(Writer writer) throws IOException {
97 writer.write("Name=" + name + LINEFEED);
98 writer.write("ExpectedVersion=" + expectedVersion + LINEFEED);