summaryrefslogtreecommitdiff
path: root/NET/worlds/network/RoomServer.java
blob: 02f80ea2a7eac14ce4e7e8231c86bbb89a04b180 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package NET.worlds.network;

import NET.worlds.core.IniFile;

public class RoomServer extends AnonRoomServer {
   @Override
   public synchronized void incRefCnt(Object referrer) {
      super.incRefCnt(referrer);
      this.startConnect();
   }

   protected void state_Authprompt() {
      this._state.setState(3);
   }

   @Override
   protected sessionInitCmd buildSessionInitCmd() {
      OldPropertyList props = new OldPropertyList();
      String username = null;
      props.addProperty(new netProperty(3, String.valueOf(this.getVersion())));
      props.addProperty(new netProperty(9, String.valueOf(this._clientVersion)));
      this._firstLogon = this._galaxy.addPendingServer(this);
      if (this._firstLogon) {
         return null;
      } else {
         int avatars = IniFile.gamma().getIniInt("avatars", 24);
         props.addProperty(new netProperty(7, Integer.toString(avatars)));

         assert this._galaxy.getChatname() != null;

         username = this._galaxy.getChatname();
         this.regShortID(1, username);
         props.addProperty(new netProperty(2, username));
         if (this._galaxy.getLoginMode() != 3 && this._galaxy.getPassword() != null) {
            props.addProperty(new netProperty(6, this._galaxy.getPassword()));
         }

         if ((getDebugLevel() & 4) > 0) {
            synchronized (System.out) {
               System.out.println(this._serverURL.getHost() + ": sending sessionInit.");

               assert username != null;

               System.out.println("  username = \"" + username + "\"");
               if (this._galaxy.getPassword() != null) {
                  System.out.println("  password = \"" + this._galaxy.getPassword() + "\"");
               }
            }
         }

         return new sessionInitCmd(props);
      }
   }

   @Override
   protected void state_Sleeping(int timeNow) {
      if (this.getGalaxy().isActive()) {
         super.state_Sleeping(timeNow);
      } else {
         this._state.setState(0);
      }
   }

   @Override
   void goOnline() {
      this._requestOffline = false;
   }
}