1 4 package com.tc.net.protocol.tcm.msgs; 5 6 import com.tc.bytes.TCByteBuffer; 7 import com.tc.io.TCByteBufferOutput; 8 import com.tc.io.TCByteBufferOutputStream; 9 import com.tc.net.protocol.tcm.MessageChannel; 10 import com.tc.net.protocol.tcm.MessageMonitor; 11 import com.tc.net.protocol.tcm.TCMessageHeader; 12 import com.tc.net.protocol.tcm.TCMessageType; 13 import com.tc.object.msg.DSOMessageBase; 14 import com.tc.object.session.SessionID; 15 import com.tc.util.SequenceGenerator; 16 17 import java.io.IOException ; 18 19 24 public class PingMessage extends DSOMessageBase { 25 private static final byte SEQUENCE = 1; 26 27 private long sequence = -1; 28 29 public PingMessage(MessageMonitor monitor, TCByteBufferOutput out, MessageChannel channel, TCMessageType type) { 30 super(monitor, out, channel, type); 31 } 32 33 public PingMessage(SessionID sessionID, MessageMonitor monitor, MessageChannel channel, TCMessageHeader header, TCByteBuffer[] data) { 34 super(sessionID, monitor, channel, header, data); 35 } 36 37 public PingMessage(MessageMonitor monitor) { 38 this(monitor, new TCByteBufferOutputStream(), null, TCMessageType.PING_MESSAGE); 39 } 40 41 public void initialize(SequenceGenerator sg) { 42 this.sequence = sg.getNextSequence(); 43 } 44 45 public PingMessage createResponse() { 46 PingMessage rv = (PingMessage) getChannel().createMessage(TCMessageType.PING_MESSAGE); 47 rv.sequence = getSequence(); 48 return rv; 49 } 50 51 protected void dehydrateValues() { 52 putNVPair(SEQUENCE, sequence); 53 } 54 55 protected boolean hydrateValue(byte name) throws IOException { 56 switch (name) { 57 case SEQUENCE: 58 sequence = getLongValue(); 59 return true; 60 default: 61 return false; 62 } 63 } 64 65 public long getSequence() { 66 return this.sequence; 67 } 68 } | Popular Tags |