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 28, 2018
1 parent cb56f5e commit 457d3cc
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 457d3cc

Please sign in to comment.