Skip to content

Commit

Permalink
enable initial p2p support features
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Sep 16, 2024
1 parent 7a0c0e9 commit a877bb2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
24 changes: 19 additions & 5 deletions app/src/main/java/org/witness/proofmode/share/p2p/ChatNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ class ChatNode(private val printMsg: OnMessage) {

fun send(message: String) {
peers.values.forEach { it.controller.send(message) }

if (message.startsWith("alias ")) {
currentAlias = message.substring(6).trim()
}
} // send

fun stop() {
Expand All @@ -62,6 +58,18 @@ class ChatNode(private val printMsg: OnMessage) {
} // stop

private fun messageReceived(id: PeerId, msg: String) {

if (msg.startsWith("notarize ")) {
var notarizeNonce = msg.split(" ")[1];

var notarizeResponse = "notarized $notarizeNonce";
send(notarizeResponse)

return;

}

/**
if (msg == "/who") {
peers[id]?.controller?.send("alias $currentAlias")
return
Expand All @@ -79,10 +87,16 @@ class ChatNode(private val printMsg: OnMessage) {
val alias = peers[id]?.name ?: id.toBase58()
printMsg("$alias > $msg")
**/

val alias = peers[id]?.name ?: id.toBase58()
printMsg("$alias > $msg")


} // messageReceived

private fun peerFound(info: PeerInfo) {
if (
if (
info.peerId == chatHost.peerId ||
knownNodes.contains(info.peerId)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ class P2PNotarizationProvider : NotarizationProvider {
`is`: InputStream?,
listener: NotarizationListener?
) {

if (listener != null) {
notarizationListener = listener
}

hash?.let {
chatNode.send(it)
chatNode.send("notarize $it")
}

}
Expand Down

0 comments on commit a877bb2

Please sign in to comment.