diff options
Diffstat (limited to 'NET/worlds/network/RoomMgr.java')
| -rw-r--r-- | NET/worlds/network/RoomMgr.java | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/NET/worlds/network/RoomMgr.java b/NET/worlds/network/RoomMgr.java new file mode 100644 index 0000000..d3c7ef0 --- /dev/null +++ b/NET/worlds/network/RoomMgr.java @@ -0,0 +1,177 @@ +/* */ package NET.worlds.network; +/* */ +/* */ import NET.worlds.core.Std; +/* */ import java.io.PrintStream; +/* */ import java.util.Enumeration; +/* */ import java.util.Hashtable; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ class RoomMgr +/* */ { +/* */ Hashtable<Integer, NetworkRoom> _roomFRoomID; +/* */ Hashtable<String, NetworkRoom> _requestList; +/* */ int _requestCount; +/* */ +/* */ public RoomMgr() +/* */ { +/* 67 */ this._roomFRoomID = new Hashtable(); +/* 68 */ this._requestList = null; +/* 69 */ this._requestCount = 0; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public synchronized void addRequest(String roomName, NetworkRoom room) +/* */ { +/* 80 */ if (this._requestCount == 0) { +/* 81 */ this._requestList = new Hashtable(); +/* */ } +/* 83 */ assert (this._requestList.get(roomName) == null); +/* 84 */ this._requestList.put(roomName, room); +/* 85 */ this._requestCount += 1; +/* */ } +/* */ +/* */ public synchronized void delRequest(String roomName) { +/* 89 */ if (this._requestList == null) +/* */ { +/* */ +/* */ +/* */ +/* 94 */ System.out.println(this + ": delRequest() - " + roomName); +/* 95 */ new Exception().printStackTrace(System.out); +/* 96 */ return; +/* */ } +/* 98 */ this._requestCount -= 1; +/* 99 */ this._requestList.remove(roomName); +/* 100 */ if (this._requestCount == 0) { +/* 101 */ this._requestList = null; +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public synchronized NetworkRoom getRequest(String roomName) +/* */ { +/* 110 */ if (this._requestList == null) +/* 111 */ return null; +/* 112 */ NetworkRoom tmpRoom = (NetworkRoom)this._requestList.get(roomName); +/* */ +/* */ +/* 115 */ if (tmpRoom != null) +/* 116 */ delRequest(roomName); +/* 117 */ return tmpRoom; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void regRoomID(int roomID, NetworkRoom room) +/* */ { +/* 126 */ NetworkRoom noRoom = (NetworkRoom)this._roomFRoomID.get(new Integer( +/* 127 */ roomID)); +/* */ +/* 129 */ if ((noRoom != null) && (noRoom != room)) +/* */ { +/* 131 */ System.out.println("[" + Std.getRealTime() + +/* 132 */ "]: Weird - room is already registered."); +/* 133 */ System.out.println("new roomID = " + roomID + ", new room = " + +/* 134 */ room); +/* 135 */ System.out.println(room.debugStuff()); +/* 136 */ System.out.println("old room is " + noRoom); +/* 137 */ System.out.println(noRoom.debugStuff()); +/* 138 */ new Exception().printStackTrace(System.out); +/* */ } +/* */ +/* 141 */ this._roomFRoomID.put(new Integer(roomID), room); +/* */ } +/* */ +/* */ public void delRoomID(int roomID, NetworkRoom delRoom) { +/* 145 */ NetworkRoom room = +/* 146 */ (NetworkRoom)this._roomFRoomID.remove(new Integer(roomID)); +/* */ +/* 148 */ if (room == null) +/* */ { +/* */ +/* 151 */ System.out.println("Error - deleting a bad roomID: " + roomID); +/* 152 */ System.out.println(delRoom.debugStuff()); +/* 153 */ new Exception().printStackTrace(System.out); +/* */ } +/* */ } +/* */ +/* */ public NetworkRoom getRoom(int roomID) +/* */ { +/* 159 */ if (roomID == 0) +/* 160 */ return null; +/* 161 */ NetworkRoom room = (NetworkRoom)this._roomFRoomID.get(new Integer(roomID)); +/* */ +/* */ +/* 164 */ return room; +/* */ } +/* */ +/* */ public Enumeration<NetworkRoom> rooms() +/* */ { +/* 169 */ return this._roomFRoomID.elements(); +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\RoomMgr.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |