View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
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.
14   *
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
18   */
19  
20  package org.xnap.plugin.overnet.net.msg.core;
21  
22  import java.nio.ByteBuffer;
23  
24  import org.apache.log4j.Logger;
25  
26  public class OptionsMessage extends OvernetCoreMessage
27  {
28  	public static final byte TYPE = (byte)199;
29  
30  	private String buildDate;
31  	private short version;
32  	private short option_doorport;
33  
34  	private String nick;
35  	private String tmpDir;
36  	private String downloadDir;
37  	private byte allowPrivateMessages;
38  	private byte saveCorrupted;
39  	private short adminPort;
40  	private int maxConnections;
41  	private int buildDateNum;
42    
43  	private float maxDownloadSpeed;
44  	private float maxUploadSpeed;
45  	private int pid;
46  
47  	private static Logger logger = Logger.getLogger(OptionsMessage.class);
48  
49  	public OptionsMessage(ByteBuffer buffer)
50  	{
51  		super(TYPE, buffer);
52  
53  		version = getShort();
54  		maxDownloadSpeed = getFloat();
55  		maxUploadSpeed = getFloat();
56  		option_doorport = getShort();
57  		// skip a short
58  		skip(2);
59  		nick = getString();
60  		logger.debug(nick);
61  		tmpDir = getString();
62  		logger.debug(tmpDir);
63  		downloadDir = getString();
64  		logger.debug(downloadDir);
65  		// skip three bytes
66  		skip(3);
67  		allowPrivateMessages = get();
68  		saveCorrupted = get();
69  		skip(1);
70  		adminPort = getShort();
71  		logger.debug("admin port " + adminPort);
72  		maxConnections = getInt();
73  		buildDateNum = getInt();
74  		pid = getInt();
75  		logger.debug("pid " + pid);
76  	}
77  }