Skip to content

Commit

Permalink
Immediate peerSend messages
Browse files Browse the repository at this point in the history
  • Loading branch information
purplesyringa committed May 26, 2018
1 parent d599eba commit 1d50538
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions plugins/P2P-messages/FileRequestPlugin.py
Expand Up @@ -127,6 +127,17 @@ def handlePeerSend(self, params):
if not result:
self.connection.badAction(10)

# Save to cache
if not websockets and raw["immediate"]:
site.p2p_unread.append({
"ip": ip,
"hash": msg_hash,
"message": raw["message"],
"signed_by": signature_address,
"cert": cert,
"broadcast": False
})


def peerCheckMessage(self, raw, params, ip):
# Calculate hash from nonce
Expand Down
3 changes: 2 additions & 1 deletion plugins/P2P-messages/UiWebsocketPlugin.py
Expand Up @@ -116,7 +116,7 @@ def p2pBroadcast(self, peer, data):
# Send a message to IP
def actionPeerSend(self, *args, **kwargs):
gevent.spawn(self.handlePeerSend, *args, **kwargs)
def handlePeerSend(self, to_, ip, message, privatekey=None, to=None):
def handlePeerSend(self, to_, ip, message, privatekey=None, to=None, immediate=False):
# Check message
if not self.peerCheckMessage(to_, message):
return
Expand All @@ -137,6 +137,7 @@ def handlePeerSend(self, to_, ip, message, privatekey=None, to=None):
# Generate hash
all_message = {
"message": message,
"immediate": immediate,
"site": self.site.address
}
if to:
Expand Down

0 comments on commit 1d50538

Please sign in to comment.