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

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

renumbered Enum (necessary, as the index of the settings combobox has changed)

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