KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > server > framework > AceIPCHeartbeatMessage


1 package com.quikj.server.framework;
2
3 public class AceIPCHeartbeatMessage implements AceIPCMessageInterface
4 {
5     /*********************************************************************************/
6     //
7
// Octet 0: msg type
8
//
9
/*********************************************************************************/
10
11     public static final int TOLERANCE_FACTOR = 3; // hb interval multiplier for reception
12

13     // constructor for message received
14
protected AceIPCHeartbeatMessage (byte[] msg, int length) throws AceException
15     {
16     message = msg;
17     msgLength = length;
18     }
19     
20     // constructor for message to be sent
21
protected AceIPCHeartbeatMessage ()
22     {
23     msgLength = MSG_HEADER_LENGTH;
24     message = new byte [msgLength];
25     
26     // fill in the message bytes
27
message [MSG_TYPE_OFFSET] = HB_MSG;
28     }
29
30     public int getIPCMsgType()
31     {
32     return message[MSG_TYPE_OFFSET];
33     }
34     
35     public int getLength()
36     {
37     return msgLength;
38     }
39     
40     public String JavaDoc traceIPCMessage(boolean entire_message)
41     {
42     if (entire_message == true)
43         {
44         return (AceIPCMessage.dumpRawBytes (message, 0, msgLength));
45         }
46     else
47         {
48         return (new String JavaDoc ("HEARTBEAT"));
49         }
50     }
51     
52     public byte[] getBytes()
53     {
54     return message;
55     }
56     
57     private static final int MSG_HEADER_LENGTH = 1;
58     
59     private byte[] message;
60     private int msgLength;
61 }
62
Popular Tags