summaryrefslogtreecommitdiff
path: root/NET/worlds/network/netPacket.java
blob: 14afa2f409b7e50d10eb5264499185f22a449865 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*     */ package NET.worlds.network;
/*     */ 
/*     */ import NET.worlds.console.StatNetMUNode;
/*     */ import java.io.IOException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public abstract class netPacket
/*     */ {
/*     */   protected ObjID _objID;
/*     */   protected int _commandType;
/*     */   
/*     */   public netPacket(ObjID id, int cmd)
/*     */   {
/*  62 */     if (id != null) {
/*  63 */       this._objID = id;
/*     */     } else
/*  65 */       this._objID = new ObjID(1);
/*  66 */     this._commandType = cmd;
/*     */   }
/*     */   
/*     */   public netPacket() {
/*  70 */     this._objID = new ObjID(1);
/*     */   }
/*     */   
/*     */   public int msgID() {
/*  74 */     return this._commandType;
/*     */   }
/*     */   
/*     */   int packetSize()
/*     */   {
/*  79 */     return 2 + this._objID.packetSize();
/*     */   }
/*     */   
/*     */   public String toString(WorldServer serv) {
/*  83 */     return new Integer(this._commandType).toString();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   void send(ServerOutputStream o)
/*     */     throws IOException
/*     */   {
/*  92 */     int packetsize = packetSize();
/*     */     
/*  94 */     if ((packetsize >= 256) && (o.getVersion() <= 24)) {
/*  95 */       throw new PacketTooLargeException();
/*     */     }
/*     */     
/*     */ 
/*     */ 
/* 100 */     StatNetMUNode netStat = StatNetMUNode.getNode();
/* 101 */     netStat.addBytesSent(packetsize);
/* 102 */     netStat.addPacketsSent(1);
/*     */     
/* 104 */     assert (this._commandType > 0);
/*     */     
/* 106 */     if ((packetsize >= 128) && (o.getVersion() > 24))
/*     */     {
/*     */ 
/* 109 */       o.writeByte(128 + packetsize / 256);
/* 110 */       o.writeByte(packetsize & 0xFF);
/*     */     }
/*     */     else {
/* 113 */       o.writeByte(packetsize);
/*     */     }
/* 115 */     this._objID.send(o);
/* 116 */     o.writeByte(this._commandType);
/*     */   }
/*     */ }


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