[Beepcore-java-commits] CVS: beepcore-java/src/org/beepcore/beep/core PiggybackedMSG.java,1.1,1.2 Ch
Status: Beta
Brought to you by:
huston
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core
In directory sc8-pr-cvs1:/tmp/cvs-serv21224/src/org/beepcore/beep/core
Modified Files:
ChannelImpl.java SessionImpl.java TuningProfile.java
TuningResetException.java
Added Files:
PiggybackedMSG.java
Log Message:
Merge from PIGGYBACK branch
Index: ChannelImpl.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/ChannelImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** ChannelImpl.java 13 Sep 2003 21:10:31 -0000 1.8
--- ChannelImpl.java 15 Sep 2003 15:23:30 -0000 1.9
***************
*** 419,422 ****
--- 419,438 ----
}
+ void abort()
+ {
+ setState(ChannelImpl.STATE_ABORTED);
+ }
+
+ void addPiggybackedMSG(PiggybackedMSG msg) throws BEEPException
+ {
+ recvMSGQueue.add(msg);
+ try {
+ callbackQueue.execute(this);
+ } catch (InterruptedException e) {
+ /** @TODO handle this better */
+ throw new BEEPException(e);
+ }
+ }
+
/**
* get the number of this <code>Channel</code> as a <code>String</code>
Index: SessionImpl.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/SessionImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** SessionImpl.java 10 Jun 2003 18:59:19 -0000 1.8
--- SessionImpl.java 15 Sep 2003 15:23:30 -0000 1.9
***************
*** 21,24 ****
--- 21,25 ----
import java.io.IOException;
+ import java.io.UnsupportedEncodingException;
import java.util.Hashtable;
***************
*** 38,41 ****
--- 39,44 ----
import org.xml.sax.SAXException;
+ import sun.misc.BASE64Decoder;
+
import org.beepcore.beep.core.event.ChannelEvent;
import org.beepcore.beep.core.event.ChannelListener;
***************
*** 86,90 ****
/** @todo check this */
! private static final int MAX_PCDATA_SIZE = 4096;
private static final int MAX_START_CHANNEL_WAIT = 60000;
private static final int MAX_START_CHANNEL_INTERVAL = 100;
--- 89,93 ----
/** @todo check this */
! static final int MAX_PCDATA_SIZE = 4096;
private static final int MAX_START_CHANNEL_WAIT = 60000;
private static final int MAX_START_CHANNEL_INTERVAL = 100;
***************
*** 960,964 ****
// Store the Channel
- ch.setState(ChannelImpl.STATE_ACTIVE);
channels.put(ch.getNumberAsString(), ch);
((MessageMSG)zero.getAppData()).sendRPY(ds);
--- 963,966 ----
***************
*** 977,981 ****
}
! private void fireChannelStarted(Channel c)
{
ChannelListener[] l = this.channelListeners;
--- 979,983 ----
}
! void fireChannelStarted(Channel c)
{
ChannelListener[] l = this.channelListeners;
***************
*** 1244,1247 ****
--- 1246,1251 ----
return;
} catch (StartChannelException e) {
+ this.enableIO();
+
try {
((MessageMSG)zero.getAppData()).sendERR(e);
***************
*** 1253,1268 ****
}
! try {
! sendProfile(p.uri, ch.getStartData(), ch);
! } catch (BEEPException e) {
! terminate("Error sending profile. " + e.getMessage());
! return;
! }
! fireChannelStarted(ch);
! if (p.data == null || ch.getState() != ChannelImpl.STATE_TUNING) {
! this.enableIO();
}
--- 1257,1307 ----
}
! if (p.data != null && ch.getStartData() == null) {
! byte[] data;
! if (p.base64Encoding) {
! try {
! data = new BASE64Decoder().decodeBuffer(p.data);
! } catch (IOException e) {
! ch.abort();
! this.enableIO();
! throw new BEEPError(BEEPError.CODE_REQUESTED_ACTION_ABORTED,
! "Error parsing piggybacked data.");
! }
! } else {
! try {
! data = p.data.getBytes("UTF-8");
! } catch (UnsupportedEncodingException e) {
! terminate("UTF-8 not supported");
! return;
! }
! }
!
! PiggybackedMSG msg = new PiggybackedMSG(ch, data,
! p.base64Encoding);
! ch.setState(ChannelImpl.STATE_STARTING);
!
! try {
! ch.addPiggybackedMSG(msg);
! } catch (BEEPException e) {
! terminate("Error sending profile. " + e.getMessage());
! return;
! }
! } else {
! try {
! sendProfile(p.uri, ch.getStartData(), ch);
! ch.setState(ChannelImpl.STATE_ACTIVE);
! } catch (BEEPException e) {
! terminate("Error sending profile. " + e.getMessage());
! return;
! }
!
! fireChannelStarted(ch);
!
! if (p.data == null && ch.getState() != ChannelImpl.STATE_TUNING) {
! this.enableIO();
! }
}
***************
*** 1270,1273 ****
--- 1309,1314 ----
}
+ this.enableIO();
+
try {
((MessageMSG)zero.getAppData()).sendERR(BEEPError.CODE_REQUESTED_ACTION_NOT_TAKEN2, "all requested profiles are unsupported");
***************
*** 1917,1922 ****
static class CLOSED_SessionOperations implements SessionOperations {
public void changeState(SessionImpl s, int newState) throws BEEPException {
! throw new BEEPException("Illegal session state transition (" +
! newState + ")");
}
--- 1958,1967 ----
static class CLOSED_SessionOperations implements SessionOperations {
public void changeState(SessionImpl s, int newState) throws BEEPException {
! if (newState == Session.SESSION_STATE_ABORTED) {
! log.equals("Error aborting, session already in a closed state.");
! } else {
! throw new BEEPException("Illegal session state transition (" +
! newState + ")");
! }
}
Index: TuningProfile.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/TuningProfile.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** TuningProfile.java 27 May 2003 21:37:41 -0000 1.10
--- TuningProfile.java 15 Sep 2003 15:23:30 -0000 1.11
***************
*** 75,79 ****
*
*/
! public void abort(BEEPError error, Channel channel) throws BEEPException
{
tuningChannels.remove(channel);
--- 75,79 ----
*
*/
! public void abort(BEEPError error, Channel channel)
{
tuningChannels.remove(channel);
***************
*** 107,110 ****
--- 107,111 ----
((ChannelImpl)channel).setState(ChannelImpl.STATE_TUNING);
session.sendProfile(profile, data, (ChannelImpl)channel);
+ ((ChannelImpl)channel).setState(ChannelImpl.STATE_ACTIVE);
session.disableIO();
} catch (Exception x) {
***************
*** 120,123 ****
--- 121,133 ----
}
}
+
+ protected void begin(Channel channel)
+ {
+ log.debug("TuningProfile.begin");
+
+ SessionImpl session = (SessionImpl)channel.getSession();
+
+ ((ChannelImpl)channel).setState(ChannelImpl.STATE_TUNING);
+ }
/**
***************
*** 134,142 ****
*/
public void complete(Channel channel,
! SessionCredential localCred,
! SessionCredential peerCred,
! SessionTuningProperties tuning,
! ProfileRegistry registry,
! Object argument)
throws BEEPException
{
--- 144,152 ----
*/
public void complete(Channel channel,
! SessionCredential localCred,
! SessionCredential peerCred,
! SessionTuningProperties tuning,
! ProfileRegistry registry,
! Object argument)
throws BEEPException
{
***************
*** 248,251 ****
--- 258,262 ----
{
((SessionImpl)session).sendProfile(uri, data, (ChannelImpl)channel);
+ ((ChannelImpl)channel).setState(ChannelImpl.STATE_ACTIVE);
}
Index: TuningResetException.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/TuningResetException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** TuningResetException.java 10 Jun 2003 18:59:20 -0000 1.3
--- TuningResetException.java 15 Sep 2003 15:23:30 -0000 1.4
***************
*** 1,3 ****
-
/*
* TuningResetException.java $Revision$ $Date$
--- 1,2 ----
***************
*** 38,41 ****
--- 37,41 ----
*
* @TODO remove this class
+ * @deprecated
*/
public TuningResetException(String message)
|