forked from Tribler/kotlin-ipv8
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Eragoneq/ipv8_integration
Ipv8 integration
- Loading branch information
Showing
10 changed files
with
288 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
ipv8/src/main/java/nl/tudelft/ipv8/messaging/payload/TransferRequestPayload.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package nl.tudelft.ipv8.messaging.payload | ||
|
||
import nl.tudelft.ipv8.messaging.Deserializable | ||
import nl.tudelft.ipv8.messaging.SERIALIZED_LONG_SIZE | ||
import nl.tudelft.ipv8.messaging.SERIALIZED_UINT_SIZE | ||
import nl.tudelft.ipv8.messaging.Serializable | ||
import nl.tudelft.ipv8.messaging.deserializeLong | ||
import nl.tudelft.ipv8.messaging.deserializeUInt | ||
import nl.tudelft.ipv8.messaging.serializeLong | ||
import nl.tudelft.ipv8.messaging.serializeUChar | ||
import nl.tudelft.ipv8.messaging.serializeUInt | ||
|
||
data class TransferRequestPayload( | ||
val port: Int, | ||
val status: TransferStatus, | ||
val dataSize: Int = 0 | ||
): Serializable { | ||
override fun serialize(): ByteArray { | ||
return serializeLong(port.toLong()) + serializeUInt(status.ordinal.toUInt()) + serializeLong(dataSize.toLong()) | ||
} | ||
|
||
companion object Deserializer : Deserializable<TransferRequestPayload> { | ||
override fun deserialize( | ||
buffer: ByteArray, | ||
offset: Int | ||
): Pair<TransferRequestPayload, Int> { | ||
var localOffset = offset | ||
|
||
val port = deserializeLong(buffer, localOffset) | ||
localOffset += SERIALIZED_LONG_SIZE | ||
val status = deserializeUInt(buffer, localOffset) | ||
localOffset += SERIALIZED_UINT_SIZE | ||
val dataSize = deserializeLong(buffer, localOffset) | ||
localOffset += SERIALIZED_LONG_SIZE | ||
|
||
return Pair(TransferRequestPayload(port.toInt(), | ||
TransferStatus.entries[status.toInt()], dataSize.toInt()), localOffset) | ||
} | ||
} | ||
|
||
enum class TransferStatus { | ||
REQUEST, | ||
ACCEPT, | ||
DECLINE | ||
} | ||
|
||
enum class TransferType { | ||
FILE, | ||
RANDOM_DATA | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
ipv8/src/main/java/nl/tudelft/ipv8/messaging/utp/UtpCommunity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package nl.tudelft.ipv8.messaging.utp | ||
|
||
import nl.tudelft.ipv8.Community | ||
|
||
class UtpCommunity : Community() { | ||
override val serviceId = "450ded7389134595dadb6b2549f431ad60156931" | ||
|
||
|
||
|
||
|
||
} |
122 changes: 0 additions & 122 deletions
122
ipv8/src/main/java/nl/tudelft/ipv8/messaging/utp/UtpEndpoint.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.