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

Last change on this file since 1696 was 1696, checked in by Paul Lelgemann, 12 years ago

o Simplified peer-to-peer settings: overlay and DHT type are now selected by architecture

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