1 package org.rosuda.REngine.Rserve;
3 import org.rosuda.REngine.Rserve.protocol.RPacket;
4 import org.rosuda.REngine.Rserve.protocol.RTalk;
6 public class RSession implements java.io.Serializable {
7 // serial version UID should only change if method signatures change
8 // significantly enough that previous versions cannot be used with
10 private static final long serialVersionUID = -7048099825974875604l;
16 transient RPacket attachPacket=null; // response on session attach
19 protected RSession() {
20 // default no-args constructor for serialization
23 RSession(RConnection c, RPacket p) throws RserveException {
25 this.rsrvVersion=c.rsrvVersion;
26 byte[] ct = p.getCont();
27 if (ct==null || ct.length!=32+3*4)
28 throw new RserveException(c, "Invalid response to session detach request.");
29 this.port = RTalk.getInt(ct, 4);
30 this.key=new byte[32];
31 System.arraycopy(ct, 12, this.key, 0, 32);
34 /** attach/resume this session */
35 public RConnection attach() throws RserveException {
36 RConnection c = new RConnection(this);
37 attachPacket = c.rt.request(-1);