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

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

removed SQLDB from trunk

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