source: trunk/CrypP2P/Internal/IP2PControl.cs @ 1374

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

+ Added P2P connection to CrypP2P based on PeerToPeerBase plugin (using default settings)
+ Added MD5Collider to CoreDeveloper solution

File size: 4.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Cryptool.Plugins.PeerToPeer;
6using Cryptool.PluginBase.Miscellaneous;
7using Cryptool.PluginBase.Control;
8
9namespace Cryptool.P2P.Internal
10{
11    #region P2P Initialisation Enums
12    public enum P2PLinkManagerType
13    {
14        Snal = 0
15    }
16
17    public enum P2PBootstrapperType
18    {
19        LocalMachineBootstrapper = 0,
20        IrcBootstrapper = 1
21    }
22
23    public enum P2POverlayType
24    {
25        FullMeshOverlay = 0
26    }
27
28    public enum P2PDHTType
29    {
30        FullMeshDHT = 0
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    #endregion
99
100    public delegate void P2PPayloadMessageReceived(PeerId sender, byte[] data);
101    public delegate void P2PSystemMessageReceived(PeerId sender, PubSubMessageType msgType);
102
103    public interface IP2PControl : IControl
104    {
105        //event P2PBase.P2PMessageReceived OnPeerReceivedMsg;
106        event P2PPayloadMessageReceived OnPayloadMessageReceived;
107        event P2PSystemMessageReceived OnSystemMessageReceived;
108
109        bool DHTstore(string sKey, byte[] byteValue);
110        bool DHTstore(string sKey, string sValue);
111        byte[] DHTload(string sKey);
112        bool DHTremove(string sKey);
113
114        bool PeerStarted();
115
116        PeerId GetPeerID(out string sPeerName);
117        PeerId GetPeerID(byte[] byteId);
118
119        /// <summary>
120        /// Sends data to the specified peer
121        /// </summary>
122        /// <param name="data">only send PAYLOAD data as an byte-array (attention:
123        /// don't add an index by yourselve, index will be added internally)</param>
124        /// <param name="destinationAddress">the address of the destination peer</param>
125        void SendToPeer(byte[] data, PeerId destinationAddress);
126        /// <summary>
127        /// Sends data to the specified peer
128        /// </summary>
129        /// <param name="sData">only send PAYLOAD data as a string</param>
130        /// <param name="destinationAddress">the address of the destination peer</param>
131        void SendToPeer(string sData, PeerId destinationAddress);
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.