summaryrefslogtreecommitdiff
path: root/NET/worlds/console/BlackBoxCommand.java
blob: 6f4f5ebed24bab413d9dc024b4813399556f5a02 (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
/*    */ package NET.worlds.console;
/*    */ 
/*    */ import NET.worlds.core.Std;
/*    */ import java.io.DataInputStream;
/*    */ import java.io.DataOutputStream;
/*    */ import java.io.IOException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public abstract class BlackBoxCommand
/*    */ {
/*    */   int commandType;
/*    */   long startTime;
/*    */   BlackBoxCallback callback;
/* 19 */   boolean waiting = false;
/*    */   
/*    */   void timestamp(long basetime) {
/* 22 */     this.startTime = (Std.getFastTime() - basetime);
/*    */   }
/*    */   
/*    */   public boolean execute(BlackBoxCallback c) {
/* 26 */     if (this.waiting) {
/* 27 */       return false;
/*    */     }
/* 29 */     this.callback = c;
/* 30 */     if (c != null) {
/* 31 */       this.waiting = true;
/*    */     }
/* 33 */     return execute();
/*    */   }
/*    */   
/*    */   abstract boolean execute();
/*    */   
/*    */   void save(DataOutputStream dos) throws IOException {
/* 39 */     dos.writeInt(this.commandType);
/* 40 */     dos.writeLong(this.startTime);
/*    */   }
/*    */   
/*    */   void load(DataInputStream dis) throws IOException {
/* 44 */     this.startTime = dis.readLong();
/*    */   }
/*    */   
/*    */   void doCallback(boolean ok) {
/* 48 */     if (this.callback != null) {
/* 49 */       this.waiting = false;
/* 50 */       this.callback.commandCompleted(this, ok);
/*    */     }
/*    */   }
/*    */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\BlackBoxCommand.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */