2 * jSite - ClientHello.java - Copyright © 2006–2012 David Roden
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package de.todesbaum.util.freenet.fcp2;
21 import java.io.IOException;
22 import java.io.Writer;
25 * Implementation of the <code>ClientHello</code> command. This command must
26 * be sent as the first command on a connection ({@link de.todesbaum.util.freenet.fcp2.Connection#connect()}
27 * takes care of that) and must not be sent afterwards.
29 * The node can answer with the following messages: <code>NodeHello</code>.
31 * @author David Roden <droden@gmail.com>
34 public class ClientHello extends Command {
36 /** The name of the client. */
37 protected String name;
39 /** The version of the FCP protocol the client expects. */
40 protected String expectedVersion = "2.0";
43 * Creates a new <code>ClientHello</code> command.
45 public ClientHello() {
46 super("ClientHello", "ClientHello-" + System.currentTimeMillis());
50 * Returns the value of the <code>ExpectedVersion</code> parameter of this
51 * command. At the moment this value is not used by the node but in the
52 * future this may be used to enforce certain node versions.
54 * @return The expected version
56 public String getExpectedVersion() {
57 return expectedVersion;
61 * Sets the value of the <code>ExpectedVersion</code> parameter of this
62 * command. At the moment this value is not used by the node but in the
63 * future this may be used to enforce certain node versions.
65 * @param expectedVersion
66 * The expected version
68 public void setExpectedVersion(String expectedVersion) {
69 this.expectedVersion = expectedVersion;
73 * Returns the name of the client that is connecting.
75 * @return The name of the client
77 public String getName() {
82 * Sets the name of the client that is connecting.
85 * The name of the client
87 public void setName(String name) {
95 protected void write(Writer writer) throws IOException {
96 writer.write("Name=" + name + LINEFEED);
97 writer.write("ExpectedVersion=" + expectedVersion + LINEFEED);