aboutsummaryrefslogtreecommitdiff
path: root/src/org/gnunet/requests/Request.java
blob: a7b9ea9639541a7ab610e56d4b82e1c632f3cf93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package org.gnunet.requests;

import org.gnunet.util.AbsoluteTime;
import org.gnunet.util.Connection;
import org.gnunet.util.RelativeTime;

/**
* ...
*
* @author Florian Dold
*/
public abstract class Request {
    protected AbsoluteTime deadline = AbsoluteTime.FOREVER;

    /**
     * Called whenever the request could not be transmitted due to timeout.
     *
     * @return
     */
    public boolean onTransmitTimeout() {
        // per default, just drop the message on timeout!
        return false;
    }

    /**
     *
     *
     * @return true if the request should be kept after the destroy request
     */
    public boolean onDestroy() {
        // per default, do not keep on destroy
        return false;
    }

    /**
     * @return true if the request should be kept after the reconnect
     */
    public boolean onReconnect() {
        // per default, do not keep on reconnect
        return false;
    }

    /**
     * @param alreadyTransmitted true if message has already been sent over the network
     */
    public void onCancel(boolean alreadyTransmitted) {
        // do nothing
    }

    public void setDeadline(AbsoluteTime deadline) {
        this.deadline = deadline;
    }

    /**
     * Called to determine after how long the request should time out.
     * Per default, the deadline is FOREVER.
     *
     * @return
     */
    public AbsoluteTime getDeadline() {
        return deadline;
    }

    public abstract void transmit(Connection.MessageSink sink);
}