MCPcopy Create free account
hub / github.com/akeranen/the-one / startTransfer

Method startTransfer

core/CBRConnection.java:45–62  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 5

getTimeMethod · 0.95
getOtherNodeMethod · 0.80
getSizeMethod · 0.80
replicateMethod · 0.45
receiveMessageMethod · 0.45

Tested by

no test coverage detected