From 22010447b53c43d554128189aa4a0d29087deb1b Mon Sep 17 00:00:00 2001 From: csunny Date: Mon, 26 Nov 2018 15:56:43 +0800 Subject: [PATCH 1/2] fix run error --- examples/chat/chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/chat/chat.py b/examples/chat/chat.py index 5c10ca16..04c72097 100755 --- a/examples/chat/chat.py +++ b/examples/chat/chat.py @@ -1,4 +1,4 @@ -#!/bin/env python3 +#!/usr/bin/env python3 import sys from os.path import dirname, abspath sys.path.append(dirname(dirname(dirname(abspath(__file__))))) From c950e065f30ed0db90ff6bf48c5c471a37177c8f Mon Sep 17 00:00:00 2001 From: csunny Date: Mon, 26 Nov 2018 16:34:38 +0800 Subject: [PATCH 2/2] Add more info for chat example --- examples/chat/chat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/chat/chat.py b/examples/chat/chat.py index 04c72097..9fd77aab 100755 --- a/examples/chat/chat.py +++ b/examples/chat/chat.py @@ -23,7 +23,7 @@ async def read_data(stream): if read_string != "\n": # Green console colour: \x1b[32m # Reset console colour: \x1b[0m - print("\x1b[32m%s\x1b[0m" % read_string) + print("\x1b[32m%s\x1b[0m> " % read_string, end="") async def write_data(stream): @@ -60,6 +60,7 @@ async def run(port, destination): print("You can replace 127.0.0.1 with public IP as well.") print("\nWaiting for incoming connection\n\n") + else: host = await new_node(transport_opt=["/ip4/127.0.0.1/tcp/%s/p2p/hostB" % port]) @@ -78,6 +79,7 @@ async def run(port, destination): asyncio.ensure_future(read_data(stream)) asyncio.ensure_future(write_data(stream)) + print("Already connected to peer %s" % addr) @click.command()