Sets a message that this connection is currently transferring. If message passing is controlled by external events, this method is not needed (but then e.g. #finalizeTransfer() and #isMessageTransferred() will not work either). Only a one message at a time can be transferred using on
(DTNHost from, Message m)
| 43 | * {@link MessageRouter#receiveMessage(Message, DTNHost)} |
| 44 | */ |
| 45 | public int startTransfer(DTNHost from, Message m) { |
| 46 | assert this.msgOnFly == null : "Already transferring " + |
| 47 | this.msgOnFly + " from " + this.msgFromNode + " to " + |
| 48 | this.getOtherNode(this.msgFromNode) + ". Can't " + |
| 49 | "start transfer of " + m + " from " + from; |
| 50 | |
| 51 | this.msgFromNode = from; |
| 52 | Message newMessage = m.replicate(); |
| 53 | int retVal = getOtherNode(from).receiveMessage(newMessage, from); |
| 54 | |
| 55 | if (retVal == MessageRouter.RCV_OK) { |
| 56 | this.msgOnFly = newMessage; |
| 57 | this.transferDoneTime = SimClock.getTime() + |
| 58 | (1.0*m.getSize()) / this.speed; |
| 59 | } |
| 60 | |
| 61 | return retVal; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Aborts the transfer of the currently transferred message. |
nothing calls this directly
no test coverage detected