diff options
Diffstat (limited to 'NET/worlds/console/ConnectionRecord.java')
| -rw-r--r-- | NET/worlds/console/ConnectionRecord.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/NET/worlds/console/ConnectionRecord.java b/NET/worlds/console/ConnectionRecord.java new file mode 100644 index 0000000..74e7867 --- /dev/null +++ b/NET/worlds/console/ConnectionRecord.java @@ -0,0 +1,47 @@ +package NET.worlds.console; + +import java.util.Date; +import java.util.Vector; + +class ConnectionRecord { + private static Vector<ConnectionRecord> recordList = new Vector<ConnectionRecord>(); + private String _who = null; + private Date _startDelayTime = null; + + public ConnectionRecord(String who) { + this._who = who; + this._startDelayTime = new Date(); + } + + public boolean isExpired(Date now) { + return now.getTime() - this._startDelayTime.getTime() > 15000L; + } + + public String getWho() { + return this._who; + } + + public static Vector<ConnectionRecord> getList() { + return recordList; + } + + public static synchronized boolean checkList(String w) { + boolean delayed = false; + int i = 0; + Date now = new Date(); + + while (!recordList.isEmpty() && i < recordList.size()) { + ConnectionRecord r = recordList.elementAt(i); + if (r.isExpired(now)) { + recordList.removeElementAt(i); + } else { + i++; + if (r.getWho().equals(w)) { + delayed = true; + } + } + } + + return delayed; + } +} |