[brlcad-commits] SF.net SVN: brlcad:[33679]
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <dav...@us...> - 2009-02-05 20:23:31
|
Revision: 33679 http://brlcad.svn.sourceforge.net/brlcad/?rev=33679&view=rev Author: davidloman Date: 2009-02-05 20:23:25 +0000 (Thu, 05 Feb 2009) Log Message: ----------- Continuing work for gsph0_Test. gsph0_Test now communicating with gsph0 during Hostname exchange and new session request. Modified Paths: -------------- rt^3/trunk/src/tests/java/gsph0_Test.java Added Paths: ----------- rt^3/trunk/src/tests/java/AbstractMsg.java rt^3/trunk/src/tests/java/GeometryManifestMsg.java rt^3/trunk/src/tests/java/GeometryReqMsg.java rt^3/trunk/src/tests/java/MsgTypes.java rt^3/trunk/src/tests/java/NetMsg.java rt^3/trunk/src/tests/java/RemHostNameSetFailMsg.java rt^3/trunk/src/tests/java/RemHostNameSetMsg.java Added: rt^3/trunk/src/tests/java/AbstractMsg.java =================================================================== --- rt^3/trunk/src/tests/java/AbstractMsg.java (rev 0) +++ rt^3/trunk/src/tests/java/AbstractMsg.java 2009-02-05 20:23:25 UTC (rev 33679) @@ -0,0 +1,231 @@ +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.UUID; + +/* N E T M S G . J A V A + * BRL-CAD + * + * Copyright (c) 1997-2009 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ + +/** + * @file NetMsg.java + * + * Description - + * + * + * Author - David Loman + * + */ + +public abstract class AbstractMsg { + private int msgType; + private String msgUUID; + private String reUUID; + + public AbstractMsg() { + + } + + public AbstractMsg(int mType, String mUUID, String rUUID) { + this.msgType = mType; + this.msgUUID = mUUID; + this.reUUID = rUUID; + } + + public AbstractMsg(byte[] data) { + this(new DataInputStream(new ByteArrayInputStream(data))); + } + + public AbstractMsg(DataInputStream dis) { + this.deserialize(dis); + } + + // "upgrader" constructor + public AbstractMsg(NetMsg msg, DataInputStream dis) { + // Get values from msg + this.msgType = msg.getMsgType(); + this.msgUUID = msg.getMsgUUID(); + this.reUUID = msg.getReUUID(); + + // then call the subclass specific deserializer + this._deserialize(dis); + } + + /* + * Serialize + */ + public byte[] Serialize() { + ByteArrayOutputStream fullBaos = new ByteArrayOutputStream(); + DataOutputStream fullDos = new DataOutputStream(fullBaos); + + this.serialize(fullDos); + + return fullBaos.toByteArray(); + } + + public void serialize(DataOutputStream fullDos) { + ByteArrayOutputStream bodyBaos = new ByteArrayOutputStream(); + DataOutputStream bodyDos = new DataOutputStream(bodyBaos); + + try { + + /* + * Serialize header elements + */ + // msgType + bodyDos.writeInt(this.getMsgType()); + + // MsgUUID + this.msgUUID = UUID.randomUUID().toString(); + bodyDos.writeInt(this.msgUUID.length()); + // Gotta do this since java Chars are Unicode + bodyDos.write(this.msgUUID.getBytes("US-ASCII")); + + // ReUUID + this.reUUID = UUID.randomUUID().toString(); + bodyDos.writeInt(this.reUUID.length()); + // Gotta do this since java Chars are Unicode + bodyDos.write(this.reUUID.getBytes("US-ASCII")); + + //for (byte b: msgUUID.getBytes("US-ASCII")) { System.out.print(b + " ");} + //System.out.println(); + + /* + * Get any subclass Body elements + */ + this._serialize(bodyDos); + + byte[] ba = bodyBaos.toByteArray(); + + /* + * Prepend the MsgLen + */ + + // Write the length of all the data in the message. + fullDos.writeInt(ba.length); + + // Write in all the data + fullDos.write(ba); + + System.out.println("Serialized an AbstractMsg with a length of " + (ba.length + 4)); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + abstract protected void _serialize(DataOutputStream dos); + + /* + * Deserialize + */ + + public void deserialize(DataInputStream dis) { + + try { + this.msgType = dis.readInt(); + + int msgUUIDlen = dis.readInt(); + byte[] baMsgUUID = new byte[msgUUIDlen]; + dis.read(baMsgUUID, 0, msgUUIDlen); + this.msgUUID = new String(baMsgUUID); + + int reUUIDlen = dis.readInt(); + byte[] baReUUID = new byte[reUUIDlen]; + dis.read(baReUUID, 0, reUUIDlen); + + //for (byte b: baReUUID) { System.out.print(b + " ");} + //System.out.println(); + + this.reUUID = new String(baReUUID); + + this._deserialize(dis); + + } catch (IOException e) { + e.printStackTrace(); + } + + } + + abstract protected void _deserialize(DataInputStream dis); + + /* + * Getters n Setters + */ + + public int getMsgType() { + return msgType; + } + + public void setMsgType(int msgType) { + this.msgType = msgType; + } + + public String getMsgUUID() { + return msgUUID; + } + + public void setMsgUUID(String msgUUID) { + this.msgUUID = msgUUID; + } + + public String getReUUID() { + return reUUID; + } + + public void setReUUID(String reUUID) { + this.reUUID = reUUID; + } + + public String toString() { + String out = ""; + out += this.getClass().getSimpleName() + "\t "; + out += "msgType: " + this.msgType + "\t "; + out += "msgUUID: " + this.msgUUID + "\t "; + out += "reUUID: " + this.reUUID + "\t "; + + out += this._toString(); + return out; + } + protected abstract String _toString(); + + public void printMe() { + System.out.println(this.toString()); + } + +} + + + + + + + + + + + + + + + + + Property changes on: rt^3/trunk/src/tests/java/AbstractMsg.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: rt^3/trunk/src/tests/java/GeometryManifestMsg.java =================================================================== --- rt^3/trunk/src/tests/java/GeometryManifestMsg.java (rev 0) +++ rt^3/trunk/src/tests/java/GeometryManifestMsg.java 2009-02-05 20:23:25 UTC (rev 33679) @@ -0,0 +1,81 @@ +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; + +public class GeometryManifestMsg extends AbstractMsg { + private ArrayList<String> items = new ArrayList<String>(); + + public GeometryManifestMsg() { + super(); + } + + public GeometryManifestMsg(byte[] data) { + super(data); + } + + public GeometryManifestMsg(DataInputStream dis) { + super(dis); + } + + public GeometryManifestMsg(int type, String muuid, String ruuid) { + super(type, muuid, ruuid); + } + + public GeometryManifestMsg(NetMsg msg, DataInputStream dis) { + super(msg, dis); + } + + @Override + protected void _deserialize(DataInputStream dis) { + try { + + int itemsInManifest = dis.readInt(); + int len = 0; + + for (int i = 0; i < itemsInManifest; ++i) { + len = dis.readInt(); + byte[] ba = new byte[len]; + dis.read(ba, 0, len); + this.items.add(new String(ba)); + + } + + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected void _serialize(DataOutputStream dos) { + try { + + // Number of Items in Manifest: + dos.writeInt(this.items.size()); + + // Items + for (String item : this.items) { + // ItemLEN + dos.writeInt(item.length()); + // Gotta do this since java Chars are Unicode + dos.write(item.getBytes("US-ASCII")); + } + + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected String _toString() { + return "Number of Items: " + this.items.size() + "\t "; + } + + /* + * Getters n Setters + */ + + public ArrayList<String> getItems() { + return items; + } +} Property changes on: rt^3/trunk/src/tests/java/GeometryManifestMsg.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: rt^3/trunk/src/tests/java/GeometryReqMsg.java =================================================================== --- rt^3/trunk/src/tests/java/GeometryReqMsg.java (rev 0) +++ rt^3/trunk/src/tests/java/GeometryReqMsg.java 2009-02-05 20:23:25 UTC (rev 33679) @@ -0,0 +1,87 @@ +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class GeometryReqMsg extends AbstractMsg { + private byte reqType; + private String data; + + public GeometryReqMsg() { + super(); + } + + public GeometryReqMsg(byte[] data) { + super(data); + } + + public GeometryReqMsg(DataInputStream dis) { + super(dis); + } + + public GeometryReqMsg(int type, String muuid, String ruuid,byte requestType, String data) { + super(type, muuid, ruuid); + this.reqType = requestType; + this.data = data; + } + + public GeometryReqMsg(NetMsg msg, DataInputStream dis) { + super(msg, dis); + } + + @Override + protected void _deserialize(DataInputStream dis) { + try { + // reqType + this.reqType = dis.readByte(); + + // data + int dataLen; + dataLen = dis.readInt(); + byte[] baData = new byte[dataLen]; + dis.read(baData, 0, dataLen); + this.data = new String(baData); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected void _serialize(DataOutputStream dos) { + try { + // reqType + dos.writeByte(this.reqType); + + // data + dos.writeInt(this.data.length()); + // Gotta do this since java Chars are Unicode + dos.write(this.data.getBytes("US-ASCII")); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected String _toString() { + return "RequestType: " + this.reqType + "\t Data: " + this.data + "\t "; + } + + /* + * Getters n Setters + */ + public byte getReqType() { + return this.reqType; + } + + public void setReqType(byte reqType) { + this.reqType = reqType; + } + + public String getData() { + return this.data; + } + + public void setData(String data) { + this.data = data; + } + +} Property changes on: rt^3/trunk/src/tests/java/GeometryReqMsg.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: rt^3/trunk/src/tests/java/MsgTypes.java =================================================================== --- rt^3/trunk/src/tests/java/MsgTypes.java (rev 0) +++ rt^3/trunk/src/tests/java/MsgTypes.java 2009-02-05 20:23:25 UTC (rev 33679) @@ -0,0 +1,18 @@ +public final class MsgTypes { + public final static int RemHostNameSET = 0; + public final static int RemHostNameSETFAIL = 5; + public final static int RemHostNameSETOK = 10; + public final static int DisconnectREQ = 15; + public final static int NewHostOnNetINFO = 20; + public final static int FullHostListREQ = 25; + public final static int FullHostListREQFAIL = 30; + public final static int FullHostListREQOK = 35; + public final static int NewSessionREQ = 40; + public final static int NewSessionREQFAIL = 45; + public final static int NewSessionREQOK = 50; + public final static int GeometryREQ = 100; + public final static int GeometryREQFAIL = 105; + public final static int GeometryMANIFEST = 110; + public final static int GeometryCHUNK = 115; + +} Property changes on: rt^3/trunk/src/tests/java/MsgTypes.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: rt^3/trunk/src/tests/java/NetMsg.java =================================================================== --- rt^3/trunk/src/tests/java/NetMsg.java (rev 0) +++ rt^3/trunk/src/tests/java/NetMsg.java 2009-02-05 20:23:25 UTC (rev 33679) @@ -0,0 +1,41 @@ +import java.io.DataInputStream; +import java.io.DataOutputStream; + + +public class NetMsg extends AbstractMsg { + + public NetMsg() { + super(); + } + + public NetMsg(byte[] data) { + super(data); + } + + public NetMsg(DataInputStream dis) { + super(dis); + } + + public NetMsg(int type, String muuid, String ruuid) { + super(type, muuid, ruuid); + } + + public NetMsg(NetMsg msg, DataInputStream dis) { + super(msg, dis); + } + + + @Override + protected void _deserialize(DataInputStream dis) { + } + + @Override + protected void _serialize(DataOutputStream dos) { + } + + @Override + protected String _toString() + { + return ""; + } +} Property changes on: rt^3/trunk/src/tests/java/NetMsg.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: rt^3/trunk/src/tests/java/RemHostNameSetFailMsg.java =================================================================== --- rt^3/trunk/src/tests/java/RemHostNameSetFailMsg.java (rev 0) +++ rt^3/trunk/src/tests/java/RemHostNameSetFailMsg.java 2009-02-05 20:23:25 UTC (rev 33679) @@ -0,0 +1,64 @@ +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class RemHostNameSetFailMsg extends AbstractMsg { + private byte failureCode; + + public RemHostNameSetFailMsg() { + super(); + } + + public RemHostNameSetFailMsg(byte[] data) { + super(data); + } + + public RemHostNameSetFailMsg(DataInputStream dis) { + super(dis); + } + + public RemHostNameSetFailMsg(int type, String muuid, String ruuid, byte failcode) { + super(type, muuid, ruuid); + this.failureCode = failcode; + } + + public RemHostNameSetFailMsg(NetMsg msg, DataInputStream dis) { + super(msg, dis); + } + + @Override + protected void _deserialize(DataInputStream dis) { + try { + this.failureCode = dis.readByte(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected void _serialize(DataOutputStream dos) { + try { + dos.write(this.failureCode); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected String _toString() { + return "FailureCode: " + this.failureCode + "\t "; + } + + /* + * Getters n Setters + */ + + public byte getHostname() { + return this.failureCode; + } + + public void setFailureCode(byte failcode) { + this.failureCode = failcode; + } + +} Property changes on: rt^3/trunk/src/tests/java/RemHostNameSetFailMsg.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: rt^3/trunk/src/tests/java/RemHostNameSetMsg.java =================================================================== --- rt^3/trunk/src/tests/java/RemHostNameSetMsg.java (rev 0) +++ rt^3/trunk/src/tests/java/RemHostNameSetMsg.java 2009-02-05 20:23:25 UTC (rev 33679) @@ -0,0 +1,72 @@ +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class RemHostNameSetMsg extends AbstractMsg { + private String hostname; + + public RemHostNameSetMsg(int type, String muuid, String ruuid, String hostname) { + super(type, muuid, ruuid); + this.hostname = hostname; + } + + public RemHostNameSetMsg() { + super(); + } + + public RemHostNameSetMsg(byte[] data) { + super(data); + } + + public RemHostNameSetMsg(DataInputStream dis) { + super(dis); + } + + public RemHostNameSetMsg(NetMsg msg, DataInputStream dis) { + super(msg, dis); + } + + @Override + protected void _deserialize(DataInputStream dis) { + try { + int hnLen; + hnLen = dis.readInt(); + byte[] baHN = new byte[hnLen]; + dis.read(baHN, 0, hnLen); + this.hostname = new String(baHN); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected void _serialize(DataOutputStream dos) { + try { + // Hostname + dos.writeInt(this.hostname.length()); + // Gotta do this since java Chars are Unicode + dos.write(this.hostname.getBytes("US-ASCII")); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + protected String _toString() + { + return "Hostname: " + this.hostname + "\t "; + } + + /* + * Getters n Setters + */ + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + +} Property changes on: rt^3/trunk/src/tests/java/RemHostNameSetMsg.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: rt^3/trunk/src/tests/java/gsph0_Test.java =================================================================== --- rt^3/trunk/src/tests/java/gsph0_Test.java 2009-02-05 20:20:20 UTC (rev 33678) +++ rt^3/trunk/src/tests/java/gsph0_Test.java 2009-02-05 20:23:25 UTC (rev 33679) @@ -1,4 +1,32 @@ -import java.io.ByteArrayOutputStream; +/* G S P H 0 _ T E S T . J A V A + * BRL-CAD + * + * Copyright (c) 1997-2009 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ + +/** @file gsph0_Test.java + * + * Description - + * + * + * Author - David Loman + * + */ + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -6,125 +34,159 @@ import java.net.UnknownHostException; import java.util.UUID; -public class gsph0_Test -{ +public class gsph0_Test { public static void main(String[] args) { Socket s; DataInputStream dis; DataOutputStream dos; - int i = 0; - + try { s = new Socket("128.63.32.72", 56789); dis = new DataInputStream(s.getInputStream()); dos = new DataOutputStream(s.getOutputStream()); - - //test sending a msg - sendRemHostNameSET(dos); - - while (++i < 20) { - - //Wait till there is enough in the input stream - while(dis.available() < 4) { - System.out.println("Have: " + dis.available() + " waiting for 4"); - Thread.sleep(10L); - } - int msgLen = dis.readInt() - 4; - - //Wait till there is enough in the input stream - while(dis.available() < msgLen) { - System.out.println("Have: " + dis.available() + " waiting for " + msgLen); - Thread.sleep(10L); - } + // Start by sending a RemHostNameSetMsg + RemHostNameSetMsg msg01 = new RemHostNameSetMsg(MsgTypes.RemHostNameSET, UUID.randomUUID().toString(), UUID.randomUUID() + .toString(), "Shota"); - System.out.println("Have: " + dis.available() + ", making msg:\n"); + // serialize it and send it to the socket + msg01.serialize(dos); + System.out.print("Sent:\t"); + msg01.printMe(); + + gsph0_Test.sendRecvLoop(dis, dos); - - int msgType = dis.readInt(); - System.out.println("\tmsgType=" + msgType + "\t\t\tLEN=4"); - System.out.println("\t\t" + dis.available() + " remaining"); - - int msgUUIDlen = dis.readInt(); - byte[] baMsgUUID = new byte[msgUUIDlen]; - dis.read(baMsgUUID, 0, msgUUIDlen); - String msgUUID = new String(baMsgUUID); - System.out.println("\tMsgUUID='" + msgUUID + "'\t LEN=" + msgUUIDlen); - System.out.println("\t\t" + dis.available() + " remaining"); - - int reUUIDlen = dis.readInt(); - byte[] baReUUID = new byte[reUUIDlen]; - dis.read(baReUUID, 0, reUUIDlen); - String reUUID = new String(baReUUID); - System.out.println("\tReUUID= '" + reUUID + "'\t LEN=" + reUUIDlen); - System.out.println("\t\t" + dis.available() + " remaining"); - - byte by= dis.readByte(); - System.out.println("\tErrorCode=" + by + "\t LEN=1"); - System.out.println("\t\t" + dis.available() + " remaining"); - - System.out.println("Have: " + dis.available() + " leftover."); - break; - } - - - - s.close(); - + } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } + } } - - public static void sendRemHostNameSET(DataOutputStream dos) { + public static void sendRecvLoop(DataInputStream sockIn, DataOutputStream sockOut) { + int loopCnt = 0; + long waitTime = 100L; + NetMsg villageMsg; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(baos); + while (loopCnt++ < 4) try { - out.writeInt(0); //msgType + System.out.println("\n\nSend/Recv Loop pass #" + loopCnt); + + /* + * RECV + */ + + // Wait till there is enough in the input stream + System.out.print("Have: " + sockIn.available() + " bytes, waiting for 4 bytes... "); + while (sockIn.available() < 4) { + Thread.sleep(waitTime); + } + System.out.println("Done."); + -// String MsgUUID = UUID.randomUUID().toString(); - String MsgUUID = "dcae96d9-a1bc-4d0c-bfbe-f3035b4fc7df"; - System.out.println(MsgUUID + " Size=" + MsgUUID.length()); - out.writeInt(MsgUUID.length()); - out.write(MsgUUID.getBytes("US-ASCII")); + int msgLen = sockIn.readInt(); + System.out.println("New MsgLen: " + msgLen + ". (" + sockIn.available() + "/" + msgLen + ")"); + + // Wait till there is enough in the input stream + while (sockIn.available() < msgLen) { + Thread.sleep(waitTime); + System.out.println("\t\t(" + sockIn.available() + "/" + msgLen + ")"); + } -// String ReUUID = UUID.randomUUID().toString(); - String ReUUID = "b01e3f29-8dd1-4d37-8d77-58a96b9348e9"; - System.out.println(ReUUID + " Size=" + ReUUID.length()); - out.writeInt(ReUUID.length()); - out.write(ReUUID.getBytes("US-ASCII")); + villageMsg = new NetMsg(sockIn); + villageMsg.printMe(); + switch (villageMsg.getMsgType()) { + case MsgTypes.RemHostNameSET: + + RemHostNameSetMsg msg1 = new RemHostNameSetMsg(villageMsg, sockIn); + msg1.printMe(); + + //Now send an OK + NetMsg okayMsg = new NetMsg(MsgTypes.RemHostNameSETOK, UUID.randomUUID().toString(), UUID.randomUUID().toString() ); + System.out.print("Sending: "); + okayMsg.serialize(sockOut); + okayMsg.printMe(); + + //Sent the OK, now wait a bit + System.out.print("\nThis app waits a bit, then requests a new Session.\n"); + Thread.sleep(2500L); + + //Now send a NewSessionRequest + NetMsg newSession = new NetMsg(MsgTypes.NewSessionREQ, UUID.randomUUID().toString(), UUID.randomUUID().toString() ); + System.out.print("Sending: "); + newSession.serialize(sockOut); + newSession.printMe(); + + break; + case MsgTypes.RemHostNameSETFAIL: + + RemHostNameSetFailMsg msg2 = new RemHostNameSetFailMsg(villageMsg, sockIn); + msg2.printMe(); + return; //Exit loop + + case MsgTypes.RemHostNameSETOK: + //NoReply Needed + break; + case MsgTypes.DisconnectREQ: + return; //Exit loop + case MsgTypes.NewHostOnNetINFO: + break; - String hostname = "Shota"; - - System.out.println(hostname + " Size=" + hostname.length()); - out.writeInt(hostname.length()); - out.write(hostname.getBytes("US-ASCII")); - - byte[] ba = baos.toByteArray(); + case MsgTypes.NewSessionREQ: + break; + case MsgTypes.NewSessionREQFAIL: + break; + case MsgTypes.NewSessionREQOK: + RemHostNameSetMsg nsReqOkay = new RemHostNameSetMsg(villageMsg, sockIn); + nsReqOkay.printMe(); + + + //Got a new Session, now wait a bit + System.out.print("\nThis app waits a bit, then requests a some Geometry.\n"); + Thread.sleep(2500L); + + //Now send a NewSessionRequest + GeometryReqMsg geoReq = new GeometryReqMsg(MsgTypes.GeometryREQ, + UUID.randomUUID().toString(), UUID.randomUUID().toString(), + (byte)1, "testing.g"); + System.out.print("Sending: "); + geoReq.serialize(sockOut); + geoReq.printMe(); + + break; + case MsgTypes.GeometryREQ: + break; + case MsgTypes.GeometryREQFAIL: + break; + case MsgTypes.GeometryMANIFEST: + break; + case MsgTypes.GeometryCHUNK: + break; + + default: + System.err.println("Unknown msgType!"); + + + break; + } - // Write the length of all the data in the message. - dos.writeInt(ba.length); - System.out.println(ba.length); - System.out.println(ba); + //Clean up the bytes here based on msgLen from above.... - - // Write in all the data - dos.write(ba); + } catch (IOException e) { e.printStackTrace(); - } + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |