EIOPacket.java
1.29 KB
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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.annotation.Nonnull
* javax.annotation.Nullable
*/
package com.adobe.granite.socketio.impl.engine;
import com.adobe.granite.socketio.impl.engine.EIOPacketType;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class EIOPacket {
public final EIOPacketType type;
public String data;
public EIOPacket(@Nonnull EIOPacketType type, @Nullable String data) {
this.type = type;
this.data = data;
}
public String encode() {
if (this.data == null) {
return this.type.code;
}
return this.type.code + this.data;
}
public static EIOPacket decode(String s) {
EIOPacketType type = EIOPacketType.valueOf(s.charAt(0));
String data = s.substring(1);
return new EIOPacket(type, data);
}
public String toString() {
StringBuilder sb = new StringBuilder("EIOPacket{");
sb.append("type=").append((Object)this.type);
sb.append(", data='");
if (this.data.length() > 50) {
sb.append(this.data.substring(0, 47)).append("...");
} else {
sb.append(this.data);
}
sb.append('\'');
sb.append('}');
return sb.toString();
}
}