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

Last change on this file since 1458 was 1458, checked in by Paul Lelgemann, 12 years ago
  • Removed unused references and using statement in CrypP2P, PeerToPeer, PeerToPeerBaseProxy

+ Skeleton for P2PEditor

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