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

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

o Extracted common classes from PeerToPeerBase plugin into new PeerToPeer plugin as a preparation for the new P2P proxy
o Modified directory properties to ignore the CrypBuild directory

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