Created
February 3, 2016 08:20
-
-
Save josejuansanchez/575e50cd591f13808e15 to your computer and use it in GitHub Desktop.
Setting up a chat network on two Raspberry Pis
This file contains hidden or 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
| # A simple internet-chat application | |
| import network | |
| import sys | |
| def heard(phrase): | |
| print("them:" + phrase) | |
| if (len(sys.argv) >= 2): | |
| network.call(sys.argv[1], whenHearCall=heard) | |
| else: | |
| network.wait(whenHearCall=heard) | |
| while network.isConnected(): | |
| #phrase = raw_input() #python2 | |
| phrase = input() # python3 | |
| print("me:" + phrase) | |
| network.say(phrase) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment