forked from zeromq/jeromq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMDP.java
53 lines (42 loc) · 945 Bytes
/
MDP.java
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
package guide;
import java.util.Arrays;
import org.zeromq.ZFrame;
import org.zeromq.ZMQ;
/**
* Majordomo Protocol definitions, Java version
*/
public enum MDP
{
/**
* This is the version of MDP/Client we implement
*/
C_CLIENT("MDPC01"),
/**
* This is the version of MDP/Worker we implement
*/
W_WORKER("MDPW01"),
// MDP/Server commands, as byte values
W_READY(1),
W_REQUEST(2),
W_REPLY(3),
W_HEARTBEAT(4),
W_DISCONNECT(5);
private final byte[] data;
MDP(String value)
{
this.data = value.getBytes(ZMQ.CHARSET);
}
MDP(int value)
{ //watch for ints>255, will be truncated
byte b = (byte) (value & 0xFF);
this.data = new byte[] { b };
}
public ZFrame newFrame()
{
return new ZFrame(data);
}
public boolean frameEquals(ZFrame frame)
{
return Arrays.equals(data, frame.getData());
}
}