01: // @(#)ESessionMsg.java 1.4 "@(#)ESessionMsg.java 1.4 99/09/23 Sun Microsystems"
02:
03: package com.sun.portal.netlet.econnection;
04:
05: import java.io.DataInputStream;
06: import java.io.DataOutputStream;
07: import java.io.IOException;
08:
09: public class ESessionMsg implements ProxyMsgConstants {
10:
11: protected byte[] id = new byte[EPROX_ID_SIZE];
12:
13: public ESessionMsg() {
14: }
15:
16: public ESessionMsg(byte[] i) {
17: System.arraycopy(i, 0, id, 0, i.length);
18: }
19:
20: public int readMsg(DataInputStream in) {
21: int rc = 0;
22:
23: try {
24: in.readFully(id, 0, EPROX_ID_SIZE);
25: // message id must be ours or else this goes to reverse proxy http
26: if (!(new String(id)).equals(EPROX_ID)) {
27: rc = -1;
28: }
29:
30: if ((new String(id)).equals(PPROX_ID)) {
31: rc = 1;
32: }
33:
34: } catch (IOException e) {
35: System.out
36: .println("ESessionMsg caught exception when reading:");
37: e.printStackTrace();
38: rc = -1;
39: }
40: return (rc);
41: }
42:
43: public int writeMsg(DataOutputStream out) {
44: int rc = 0;
45:
46: try {
47: out.write(id, 0, EPROX_ID_SIZE);
48: out.flush();
49: } catch (IOException e) {
50: System.out
51: .println("ESessionMsg caught exception when writing:");
52: e.printStackTrace();
53: rc = -1;
54: }
55: return (rc);
56: }
57:
58: public byte[] getESessionId() {
59: if (id != null) {
60: byte[] i = new byte[id.length];
61: System.arraycopy(id, 0, i, 0, id.length);
62: return (i);
63: } else {
64: return (null);
65: }
66: }
67: }
|