3 * An interface for package receivers
5 * @author Roland Haeder <webmaster@shipsimu.org>
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
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.
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.
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/>.
24 interface Receivable extends FrameworkInterface {
26 * Checks whether new raw data from the socket has arrived
28 * @return $hasArrived Whether raw package data has arrived at a socket
30 function isNewRawDataPending ();
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
39 function handleIncomingDecodedData ();
42 * Checks whether incoming decoded data is handled.
44 * @return $isHandled Whether incoming decoded data is handled
46 function isIncomingRawDataHandled ();
49 * Assembles incoming decoded data so it will become an abstract network
54 function assembleDecodedDataToPackage ();
57 * Checks whether a new message has arrived
59 * @return $hasArrived Whether a new message has arrived for processing
61 function isNewMessageArrived ();
64 * Handle newly arrived message
68 function handleNewlyArrivedMessage ();
71 * Checks whether a processed message is pending for "interpretation"
73 * @return $isPending Whether a processed message is pending
75 function isProcessedMessagePending ();
78 * Handle processed messages by "interpreting" the 'message_type' element
82 function handleProcessedMessage ();
85 * Adds raw decoded data from the given handler instance to this receiver
87 * @param $handlerInstance An instance of a Networkable class
90 function addRawDataToIncomingStack (Networkable $handlerInstance);
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).
96 * @param $rawPackageContent The raw package content to be "decoded"
97 * @return $decodedData The real package data that the sender has sent
99 function decodeRawContent ($rawPackageContent);
102 * Checks whether the assembler has pending data left
104 * @return $isHandled Whether the assembler has pending data left
106 function ifAssemblerHasPendingDataLeft ();
109 * Handles the attached assemler's pending data queue to be finally
110 * assembled to the raw package data back.
114 function handleAssemblerPendingData ();
117 * Handles decoded data for this node
119 * @param $decodedData An array with decoded raw package data
122 function handleRawData (array $decodedData);
125 * Checks whether the assembler has multiple messages pending
127 * @return $isPending Whether the assembler has multiple messages pending
129 function ifMultipleMessagesPending ();
132 * Handles multiple messages.
136 function handleMultipleMessages ();
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.
144 * @param $messageData Array with message data
147 function feedHashToMiner (array $messageData);