source: trunk/CrypPlugins/PeerToPeer/IP2PControl.cs @ 1672

Last change on this file since 1672 was 1672, checked in by Matthäus Wander, 12 years ago

P2P:

  • new pap dlls based on pap rev. 5081
  • settings change to make ct2 compile against new pap dlls
  • added chord overlay+dht
File size: 4.5 KB
Line 
1using Cryptool.PluginBase.Control;
2
3namespace Cryptool.Plugins.PeerToPeer.Internal
4{
5
6    #region P2P Initialisation Enums
7
8    public enum P2PLinkManagerType
9    {
10        Snal = 0
11    }
12
13    public enum P2PBootstrapperType
14    {
15        LocalMachineBootstrapper = 0,
16        IrcBootstrapper = 1
17    }
18
19    public enum P2POverlayType
20    {
21        FullMeshOverlay = 0,
22        ChordOverlay = 1
23    }
24
25    public enum P2PDHTType
26    {
27        FullMeshDHT = 0,
28        ChordDHT = 1
29    }
30
31    public enum P2PTransportProtocol
32    {
33        TCP = 0,
34        TCP_UDP = 1,
35        UDP = 2
36    }
37
38    /// <summary>
39    /// Message types for maintaining the Publish/Subscriber systems
40    /// </summary>
41    public enum PubSubMessageType
42    {
43        /// <summary>
44        /// To register the subscriber with the publisher
45        /// </summary>
46        Register = 0,
47        /// <summary>
48        /// adequate response to a subscriber-sided
49        /// registering message
50        /// </summary>
51        RegisteringAccepted = 1,
52        /// <summary>
53        /// when peer wants to leave the publish/subscriber union
54        /// </summary>
55        Unregister = 2,
56        /// <summary>
57        /// To signalize the publisher that subscriber is still online/alive
58        /// </summary>
59        Alive = 3,
60        /// <summary>
61        /// active liveliness-request, the other side
62        /// must respond with a pong message
63        /// </summary>
64        Ping = 4,
65        /// <summary>
66        /// adequate response to a
67        /// received ping message
68        /// </summary>
69        Pong = 5,
70        /// <summary>
71        /// subscriber sends this msg when solution was found
72        /// </summary>
73        Solution = 6,
74        /// <summary>
75        /// to immediately stop the subscribers work
76        /// </summary>
77        Stop = 7,
78        /// <summary>
79        /// When a new Publisher A canceled to takeover the Topic of another Publisher B,
80        /// because B is still active, so A can't takeover functionality of B!
81        /// </summary>
82        PublisherRivalryProblem = 8,
83        /// <summary>
84        /// Only send this msg type, when a fatal error occured at Publisher or Subscriber
85        /// </summary>
86        Error = 222
87    }
88
89    /// <summary>
90    /// necessary index for all p2p messages, which have to be processed by ct2
91    /// </summary>
92    public enum P2PMessageIndex
93    {
94        /// <summary>
95        /// indicates, that a PubSubMessageType will follow
96        /// </summary>
97        PubSub = 0,
98        /// <summary>
99        /// indicates, that any kind of payload data will follow
100        /// </summary>
101        Payload = 1
102    }
103
104    #endregion
105
106    public delegate void P2PPayloadMessageReceived(PeerId sender, byte[] data);
107
108    public delegate void P2PSystemMessageReceived(PeerId sender, PubSubMessageType msgType);
109
110    public interface IP2PControl : IControl
111    {
112        //event P2PBase.P2PMessageReceived OnPeerReceivedMsg;
113        event P2PPayloadMessageReceived OnPayloadMessageReceived;
114        event P2PSystemMessageReceived OnSystemMessageReceived;
115
116        bool DHTstore(string sKey, byte[] byteValue);
117        bool DHTstore(string sKey, string sValue);
118        byte[] DHTload(string sKey);
119        bool DHTremove(string sKey);
120
121        bool PeerStarted();
122
123        PeerId GetPeerID(out string sPeerName);
124        PeerId GetPeerID(byte[] byteId);
125
126        /// <summary>
127        /// Sends data to the specified peer
128        /// </summary>
129        /// <param name="data">only send PAYLOAD data as an byte-array (attention:
130        /// don't add an index by yourselve, index will be added internally)</param>
131        /// <param name="destinationAddress">the address of the destination peer</param>
132        void SendToPeer(byte[] data, PeerId destinationAddress);
133
134        /// <summary>
135        /// Sends data to the specified peer
136        /// </summary>
137        /// <param name="sData">only send PAYLOAD data as a string</param>
138        /// <param name="destinationAddress">the address of the destination peer</param>
139        void SendToPeer(string sData, PeerId destinationAddress);
140
141        /// <summary>
142        /// Sends data to the specified peer
143        /// </summary>
144        /// <param name="msgType">a PubSub-System message</param>
145        /// <param name="sDestinationAddress">the address of the destination peer</param>
146        void SendToPeer(PubSubMessageType msgType, PeerId sDestinationAddress);
147    }
148}
Note: See TracBrowser for help on using the repository browser.