Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: marauroa/net/MessageC2SLogin.java


1   /* $Id: MessageC2SLogin.java,v 1.2 2003/12/08 01:08:30 arianne_rpg Exp $ */
2   /***************************************************************************
3    *                      (C) Copyright 2003 - Marauroa                      *
4    ***************************************************************************
5    ***************************************************************************
6    *                                                                         *
7    *   This program is free software; you can redistribute it and/or modify  *
8    *   it under the terms of the GNU General Public License as published by  *
9    *   the Free Software Foundation; either version 2 of the License, or     *
10   *   (at your option) any later version.                                   *
11   *                                                                         *
12   ***************************************************************************/
13  package marauroa.net;
14    
15  import java.net.InetSocketAddress;
16  import java.io.*;
17    
18  /** This message indicate the server that the client wants to login and send the
19   *  needed info: username and password to login to server.
20   *  @see marauroa.net.Message
21   */
22  public class MessageC2SLogin extends Message
23    {
24    private String username;
25    private String password;
26    
27    /** Constructor for allowing creation of an empty message */
28    public MessageC2SLogin()
29      {
30      super(null);
31      
32      type=TYPE_C2S_LOGIN;
33      }
34  
35    /** Constructor with a TCP/IP source/destination of the message and the name
36     *  of the choosen character.
37     *  @param source The TCP/IP address associated to this message
38     *  @param username the username of the user that wants to login
39     *  @param password the plain password of the user that wants to login
40     */
41    public MessageC2SLogin(InetSocketAddress source,String username, String password)
42      {
43      super(source);
44      
45      type=TYPE_C2S_LOGIN;
46      this.username=username;
47      this.password=password;
48      }  
49    
50    /** This method returns the username
51     *  @return the username */
52    public String getUsername()
53      {
54      return username;    
55      }
56      
57    /** This method returns the password
58     *  @return the password */
59    public String getPassword()
60      {
61      return password;
62      }
63  
64    /** This method returns a String that represent the object 
65     *  @return a string representing the object.*/
66    public String toString()
67      {
68      return "Message (C2S Login) from ("+source.toString()+") CONTENTS: (username:"+username+"\tpassword:"+password+")";
69      }
70        
71    public void writeObject(marauroa.net.OutputSerializer out) throws IOException
72      {
73      super.writeObject(out);
74      out.write(username);
75      out.write(password);
76      }
77      
78    public void readObject(marauroa.net.InputSerializer in) throws IOException, java.lang.ClassNotFoundException
79      {
80      super.readObject(in);
81      username=in.readString();
82      password=in.readString();
83      
84      if(type!=TYPE_C2S_LOGIN)
85        {
86        throw new java.lang.ClassNotFoundException();
87        }
88      }    
89    };
90  
91  
92