]> git.mxchange.org Git - hub.git/blob - application/hub/interfaces/package/class_Receivable.php
The package hash needs to be copied to the message array as it needs to be
[hub.git] / application / hub / interfaces / package / class_Receivable.php
1 <?php
2 /**
3  * An interface for package receivers
4  *
5  * @author              Roland Haeder <webmaster@shipsimu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.shipsimu.org
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 interface Receivable extends FrameworkInterface {
25         /**
26          * Checks whether new raw data from the socket has arrived
27          *
28          * @return      $hasArrived             Whether raw package data has arrived at a socket
29          */
30         function isNewRawDataPending ();
31
32         /**
33          * Handles the incoming decoded raw data. This method does not "convert" the
34          * decoded data back into a package array, it just "handles" it and pushs it
35          * on the next stack.
36          *
37          * @return      void
38          */
39         function handleIncomingDecodedData ();
40
41         /**
42          * Checks whether incoming decoded data is handled.
43          *
44          * @return      $isHandled      Whether incoming decoded data is handled
45          */
46         function isIncomingRawDataHandled ();
47
48         /**
49          * Assembles incoming decoded data so it will become an abstract network
50          * package again.
51          *
52          * @return      void
53          */
54         function assembleDecodedDataToPackage ();
55
56         /**
57          * Checks whether a new message has arrived
58          *
59          * @return      $hasArrived             Whether a new message has arrived for processing
60          */
61         function isNewMessageArrived ();
62
63         /**
64          * Handle newly arrived message
65          *
66          * @return      void
67          */
68         function handleNewlyArrivedMessage ();
69
70         /**
71          * Checks whether a processed message is pending for "interpretation"
72          *
73          * @return      $isPending      Whether a processed message is pending
74          */
75         function isProcessedMessagePending ();
76
77         /**
78          * Handle processed messages by "interpreting" the 'message_type' element
79          *
80          * @return      void
81          */
82         function handleProcessedMessage ();
83
84         /**
85          * Adds raw decoded data from the given handler instance to this receiver
86          *
87          * @param       $handlerInstance        An instance of a Networkable class
88          * @return      void
89          */
90         function addRawDataToIncomingStack (Networkable $handlerInstance);
91
92         /**
93          * "Decode" the package content. This method does also verify the attached hash
94          * against the real raw package data (that what the sender has sent).
95          *
96          * @param       $rawPackageContent      The raw package content to be "decoded"
97          * @return      $decodedData            The real package data that the sender has sent
98          */
99         function decodeRawContent ($rawPackageContent);
100
101         /**
102          * Checks whether the assembler has pending data left
103          *
104          * @return      $isHandled      Whether the assembler has pending data left
105          */
106         function ifAssemblerHasPendingDataLeft ();
107
108         /**
109          * Handles the attached assemler's pending data queue to be finally
110          * assembled to the raw package data back.
111          *
112          * @return      void
113          */
114         function handleAssemblerPendingData ();
115
116         /**
117          * Handles decoded data for this node
118          *
119          * @param       $decodedData    An array with decoded raw package data
120          * @return      void
121          */
122         function handleRawData (array $decodedData);
123
124         /**
125          * Checks whether the assembler has multiple messages pending
126          *
127          * @return      $isPending      Whether the assembler has multiple messages pending
128          */
129         function ifMultipleMessagesPending ();
130
131         /**
132          * Handles multiple messages.
133          *
134          * @return      void
135          */
136         function handleMultipleMessages ();
137
138         /**
139          * Feeds the hash and sender (as recipient for the 'sender' reward) to the
140          * miner's queue, unless the message is not a "reward claim" message as this
141          * leads to an endless loop. You may wish to run the miner to get some
142          * reward ("HubCoins") for "mining" this hash.
143          *
144          * @param       $messageData    Array with message data
145          * @return      void
146          */
147         function feedHashToMiner (array $messageData);
148 }
149
150 // [EOF]
151 ?>