[Beepcore-java-commits] CVS: beepcore-java/src/org/beepcore/beep/core Channel.java,1.18,1.19 Message
Status: Beta
Brought to you by:
huston
|
From: Huston F. <hu...@us...> - 2001-11-12 16:12:44
|
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core
In directory usw-pr-cvs1:/tmp/cvs-serv23001
Modified Files:
Channel.java Message.java
Log Message:
Removed dead code
Index: Channel.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/Channel.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** Channel.java 2001/11/09 19:10:58 1.18
--- Channel.java 2001/11/12 16:12:41 1.19
***************
*** 1,6 ****
/*
! * Channel.java $Revision$ $Date$
*
* Copyright (c) 2001 Invisible Worlds, Inc. All rights reserved.
*
* The contents of this file are subject to the Blocks Public License (the
--- 1,7 ----
/*
! * Channel.java $Revision$ $Date$
*
* Copyright (c) 2001 Invisible Worlds, Inc. All rights reserved.
+ * Copyright (c) Huston Franklin. All rights reserved.
*
* The contents of this file are subject to the Blocks Public License (the
***************
*** 60,64 ****
private static final String ERR_REPLY_RECEIVED_FOR_NO_MESSAGE =
"Reply received for a message never sent.";
- private static final int MAX_PAYLOAD_SIZE = 4096;
private static final BufferSegment zeroLengthSegment =
new BufferSegment(new byte[0]);
--- 61,64 ----
***************
*** 104,110 ****
private LinkedList pendingSendMessages;
- /** size of the frames */
- private int frameSize;
-
/** session this channel sends through. */
private Session session;
--- 104,107 ----
***************
*** 131,144 ****
private int prevWindowUsed;
-
- private int waitTimeForPeer;
! private boolean notifyOnFirstFrame;
private Object applicationData = null;
- /* this is to support deprecated sendXXX methods */
- private MessageMSG currentMSG;
-
// in shutting down the session
// something for waiting synchronous messages (semaphores or something)
--- 128,136 ----
private int prevWindowUsed;
! private boolean notifyOnFirstFrame = true;
private Object applicationData = null;
// in shutting down the session
// something for waiting synchronous messages (semaphores or something)
***************
*** 165,169 ****
this.listener = listener;
this.session = session;
- this.frameSize = MAX_PAYLOAD_SIZE;
sentSequence = 0;
recvSequence = 0;
--- 157,160 ----
***************
*** 180,185 ****
prevWindowUsed = 0;
peerWindowSize = DEFAULT_WINDOW_SIZE;
- waitTimeForPeer = 0;
- this.notifyOnFirstFrame = true;
}
--- 171,174 ----
***************
*** 323,353 ****
/**
- * Determines whether calls to the <code>MessageListener</code> are
- * made upon receiving the first or last <code>Frame</code> of the message.
- *
- * @param n If <code>true</code>, calls to <code>MessageListener</code> are
- * received on the first <code>Frame</code> of a message. Otherwise, the
- * <code>MessageListener</code> will be called once the message is complete
- * (when the last <code>Frame</code> is received).
- *
- * @see MessageListener
- */
- void setNotifyMessageListenerOnFirstFrame(boolean n)
- {
- this.notifyOnFirstFrame = n;
- }
-
- /**
- * Returns whether or not calls to the <code>MessageListener</code> are
- * made upon receiving the first or last <code>Frame</code> of the message.
- *
- * @see #setNotifyMessageListenerOnFirstFrame
- */
- boolean getNotifyMessageListenerOnFirstFrame()
- {
- return this.notifyOnFirstFrame;
- }
-
- /**
* Sets the <code>MessageListener</code> for this channel.
*
--- 312,315 ----
***************
*** 520,524 ****
}
- this.currentMSG = m;
((MessageListener) this.listener).receiveMSG(m);
--- 482,485 ----
***************
*** 848,852 ****
}
! void sendToPeer(MessageStatus status) throws BEEPException
{
synchronized (pendingSendMessages) {
--- 809,813 ----
}
! private void sendToPeer(MessageStatus status) throws BEEPException
{
synchronized (pendingSendMessages) {
***************
*** 962,1122 ****
status.setMessageStatus(MessageStatus.MESSAGE_STATUS_SENT);
- }
-
- /*
- synchronized void sendToPeer(MessageStatus status) throws BEEPException
- {
- Frame frame = null;
- int available = 0;
- OutputDataStream stream;
- byte[] payload;
- int sessionBufferSize;
-
- // allocate a shared buffer for this message
- // @todo This call should be changed
- sessionBufferSize = session.getMaxFrameSize();
- payload = new byte[sessionBufferSize];
-
- // get the message data
- stream = status.getMessageData();
-
- if (stream == null ||
- (stream.availableSegment() == false && stream.isComplete()))
- {
- Log.logEntry(Log.SEV_DEBUG, "Sending NUL or size 0 frame");
- frame = new Frame(status.getMessageType(),
- status.getChannel(), status.getMsgno(), true,
- sentSequence, 0, status.getAnsno());
- try {
- session.sendFrame(frame);
- } catch (BEEPException e) {
- Log.logEntry(Log.SEV_ERROR, e);
- status.setMessageStatus(MessageStatus.MESSAGE_STATUS_NOT_SENT);
-
- throw e;
- }
-
- // set the status to sent and return it
- status.setMessageStatus(MessageStatus.MESSAGE_STATUS_SENT);
-
- return;
- }
-
- // while we still have data to read
- available = stream.availableHeadersAndData();
-
- synchronized (this) {
- msgsPending++;
- }
-
- // for this message, is there anything waiting?
- boolean done = false;
- while (!done) {
- try {
- synchronized (this) {
-
- // make sure the other peer can accept something
- if (peerWindowSize == 0) {
- wait(waitTimeForPeer);
-
- // wait until there is something to send up to
- // our timeout
- if (peerWindowSize == 0) {
- throw new BEEPException("Time expired waiting " +
- "for peer.");
- }
- }
-
- // how much should we send?
- int maxCanRead = 0;
-
- // we should send the least of these:
- // 1) the size of the send buffer in the session
- // (transport specific)
- maxCanRead = sessionBufferSize;
-
- // 2) the amount our peer can accept
- if (maxCanRead > peerWindowSize) {
- maxCanRead = peerWindowSize;
- }
-
- int amountToSend = stream.readHeadersAndData(payload, 0,
- maxCanRead);
- if ((stream.available() == 0) && stream.isComplete()) {
- done = true;
- }
- else if (amountToSend == -1) {
- done = true;
- // send an empty payload
- payload = new byte[0];
- amountToSend = 0;
- }
-
- // create a frame
- frame =
- new Frame(status.getMessageType(),
- status.getChannel(), status.getMsgno(),
- done ? true : false,
- sentSequence, status.getAnsno(),
- new BufferSegment(payload, 0,
- amountToSend));
-
- // update the sequence and peer window size
- sentSequence += amountToSend; // update the sequence
- peerWindowSize -= amountToSend;
- }
-
- // send it
- if (done) {
- Log.logEntry(Log.SEV_DEBUG_VERBOSE,
- "Channel.sendToPeer sending last frame on channel "
- + number);
- } else {
- Log.logEntry(Log.SEV_DEBUG_VERBOSE,
- "Channel.sendToPeer sending a frame on channel "
- + number);
- }
- } catch (Exception e) {
- Log.logEntry(Log.SEV_ERROR, e);
- status.setMessageStatus(MessageStatus.MESSAGE_STATUS_NOT_SENT);
-
- throw new BEEPException(e.getMessage());
- }
-
- try {
- session.sendFrame(frame);
- } catch (BEEPException e) {
- Log.logEntry(Log.SEV_ERROR, e);
- status.setMessageStatus(MessageStatus.MESSAGE_STATUS_NOT_SENT);
-
- synchronized (this) {
- msgsPending--;
-
- if (msgsPending == 0) {
- notify();
- }
- }
-
- return;
- }
- }
-
- // set the status to sent and return it
- status.setMessageStatus(MessageStatus.MESSAGE_STATUS_SENT);
-
- synchronized (this) {
- msgsPending--;
-
- if (msgsPending == 0) {
- notify();
- }
- }
- }
- */
-
- // used by session to control the frame size of the channel
- void setFrameSize(int frameSize)
- {
- this.frameSize = frameSize;
}
--- 923,926 ----
Index: Message.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/Message.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** Message.java 2001/11/08 05:51:34 1.7
--- Message.java 2001/11/12 16:12:41 1.8
***************
*** 67,77 ****
public static final int MESSAGE_TYPE_NUL = 5;
- /**
- * BEEP message type for utility only.
- */
- private static final int MESSAGE_TYPE_MAX = 6;
-
- private static final String NOT_MESSAGE_TYPE_MSG =
- "Message is not of type MSG";
/** BEEP message type of <code>Message</code>. */
int messageType = MESSAGE_TYPE_UNK;
--- 67,70 ----
***************
*** 85,88 ****
--- 78,90 ----
/** Answer number of this BEEP message. */
int ansno;
+
+ /**
+ * BEEP message type for utility only.
+ */
+ private static final int MESSAGE_TYPE_MAX = 6;
+
+ private static final String NOT_MESSAGE_TYPE_MSG =
+ "Message is not of type MSG";
+
private boolean notified = false;
|