01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.net.protocol.delivery;
06:
07: import com.tc.bytes.TCByteBuffer;
08: import com.tc.net.protocol.TCNetworkMessage;
09:
10: public class OOOProtocolMessageFactory {
11:
12: public OOOProtocolMessage createNewHandshakeMessage(
13: short sessionId, long ack) {
14: return new OOOProtocolMessageImpl(
15: new OOOProtocolMessageHeader(
16: OOOProtocolMessageHeader.VERSION,
17: OOOProtocolMessageHeader.TYPE_HANDSHAKE, ack,
18: sessionId));
19: }
20:
21: public OOOProtocolMessage createNewAckMessage(short sessionId,
22: long sequence) {
23: return new OOOProtocolMessageImpl(new OOOProtocolMessageHeader(
24: OOOProtocolMessageHeader.VERSION,
25: OOOProtocolMessageHeader.TYPE_ACK, sequence, sessionId));
26: }
27:
28: public OOOProtocolMessage createNewSendMessage(short sessionId,
29: long sequence, TCNetworkMessage payload) {
30: return new OOOProtocolMessageImpl(
31: new OOOProtocolMessageHeader(
32: OOOProtocolMessageHeader.VERSION,
33: OOOProtocolMessageHeader.TYPE_SEND, sequence,
34: sessionId), payload);
35: }
36:
37: public OOOProtocolMessage createNewMessage(
38: OOOProtocolMessageHeader header, TCByteBuffer[] data) {
39: return new OOOProtocolMessageImpl(header, data);
40: }
41:
42: public OOOProtocolMessage createNewGoodbyeMessage(short sessionId) {
43: return new OOOProtocolMessageImpl(new OOOProtocolMessageHeader(
44: OOOProtocolMessageHeader.VERSION,
45: OOOProtocolMessageHeader.TYPE_GOODBYE, 0, sessionId));
46: }
47:
48: public OOOProtocolMessage createNewHandshakeReplyOkMessage(
49: short sessionId, long sequence) {
50: return new OOOProtocolMessageImpl(new OOOProtocolMessageHeader(
51: OOOProtocolMessageHeader.VERSION,
52: OOOProtocolMessageHeader.TYPE_HANDSHAKE_REPLY_OK,
53: sequence, sessionId));
54: }
55:
56: public OOOProtocolMessage createNewHandshakeReplyFailMessage(
57: short sessionId, long sequence) {
58: return new OOOProtocolMessageImpl(new OOOProtocolMessageHeader(
59: OOOProtocolMessageHeader.VERSION,
60: OOOProtocolMessageHeader.TYPE_HANDSHAKE_REPLY_FAIL,
61: sequence, sessionId));
62: }
63: }
|