1 package com.quikj.server.framework; 2 3 public class AceIPCConnRespMessage implements AceIPCMessageInterface 4 { 5 6 15 16 public static final int STATUS_OK = 0; 18 public static final int STATUS_REFUSED = 1; 19 public static final int STATUS_TRY_LATER = 2; 20 21 protected AceIPCConnRespMessage (byte[] msg, int length) throws AceException 23 { 24 message = msg; 25 msgLength = length; 26 status = message [STATUS_OFFSET]; 27 try 28 { 29 hbInterval = (int) AceInputSocketStream.octetsToIntMsbFirst (message, 30 HB_INTERVAL_OFFSET, 31 4); 32 } 33 catch (NumberFormatException ex) 34 { 35 throw new AceException ("NumberFormatException while decoding AceIPCConnRespMessage HB interval"); 36 } 37 } 38 39 protected AceIPCConnRespMessage (int status, int hb_interval) 41 { 42 msgLength = MSG_HEADER_LENGTH; 43 message = new byte [msgLength]; 44 this.status = status; 45 hbInterval = hb_interval; 46 47 message [MSG_TYPE_OFFSET] = CONN_RESP_MSG; 49 message [STATUS_OFFSET] = (byte) status; 50 AceInputSocketStream.intToBytesMsbFirst (hbInterval, message, HB_INTERVAL_OFFSET); 51 } 52 53 public int getIPCMsgType() 54 { 55 return message[MSG_TYPE_OFFSET]; 56 } 57 58 public int getLength() 59 { 60 return msgLength; 61 } 62 63 public String traceIPCMessage(boolean entire_message) 64 { 65 if (entire_message == true) 66 { 67 return (AceIPCMessage.dumpRawBytes (message, 0, msgLength)); 68 } 69 else 70 { 71 return (new String ("CONNECT RESPONSE")); 72 } 73 } 74 75 public byte[] getBytes() 76 { 77 return message; 78 } 79 80 public int getStatus() 81 { 82 return status; 83 } 84 85 public int getHbInterval() 86 { 87 return hbInterval; 88 } 89 90 private static final int MSG_HEADER_LENGTH = 6; 91 private static final int STATUS_OFFSET = 1; 92 private static final int HB_INTERVAL_OFFSET = 2; 93 94 private byte[] message; 95 private int msgLength; 96 private int status; 97 private int hbInterval; 98 } 99 | Popular Tags |