aboutsummaryrefslogtreecommitdiff
path: root/src/org/gnunet/mesh/Mesh.java
blob: d739b6190f91828c48a62a6d7fae7eb5aadbc7aa (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 This file is part of GNUnet.
 (C) 2011, 2012 Christian Grothoff (and other contributing authors)

 GNUnet is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published
 by the Free Software Foundation; either version 3, or (at your
 option) any later version.

 GNUnet is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with GNUnet; see the file COPYING.  If not, write to the
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.
 */

package org.gnunet.mesh;

import org.gnunet.requests.Request;
import org.gnunet.requests.RequestQueue;
import org.gnunet.util.*;
import org.grothoff.Runabout;

import java.util.List;

/**
 * @author Florian Dold
 */
public class Mesh {
    private RequestQueue requestQueue;
    private TunnelEndHandler tunnelEndHandler;
    private Runabout messageReceiver;
    private List<Integer> applications;
    private InboundTunnelHandler inboundTunnelHandler;


    public static class RootTunnel {
        int tunnel_id;
        public void addPeer(PeerIdentity peerIdentity) {

        }
        public void blacklist(PeerIdentity peerIdentity) {

        }
        public void destroy() {
            // ...
        }
    }

    public static class Tunnel extends RootTunnel {
        public Cancelable notifyTransmitReady(PeerIdentity target) {
            return null;
        }
    }


    public class ClientConnectRequest extends Request {

        @Override
        public void transmit(Connection.MessageSink sink) {
            //To change body of implemented methods use File | Settings | File Templates.
        }
    }


    private class MeshMessageReceiver extends RunaboutMessageReceiver {

        @Override
        public void handleError() {
        }
    }


    public Mesh(Configuration cfg, InboundTunnelHandler inboundTunnelHandler,
                TunnelEndHandler tunnelEndHandler, Runabout messageReceiver, List<Integer> applications) {
        this.tunnelEndHandler = tunnelEndHandler;
        this.messageReceiver = messageReceiver;
        this.applications = applications;
        this.inboundTunnelHandler = inboundTunnelHandler;

        Client client = new Client("mesh", cfg);
        requestQueue = new RequestQueue(client, new MeshMessageReceiver());

        requestQueue.add(new ClientConnectRequest());

    }

    /**
     * Create a new tunnel (we're initiator and will be allowed to add/remove peers
     * and to broadcast).
     */
    public RootTunnel createTunnel(/* ... */) {
        return null;
    }

    /**
     * Disconnect from the mesh service. All tunnels will be destroyed. All tunnel
     * disconnect callbacks will be called on any still connected peers, notifying
     * about their disconnection. The registered inbound tunnel cleaner will be
     * called should any inbound tunnels still exist.
     */
    public void disconnect() {

    }
}