-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c638bf9
commit e6e3f39
Showing
6 changed files
with
97 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import sys, os | ||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) | ||
import scratchcommunication# | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
USERNAME, PASSWORD = os.getenv("SCRATCH_USERNAME"), os.getenv("SCRATCH_PASSWORD") | ||
PROJECT_ID = os.getenv("PROJECT_ID") | ||
|
||
|
||
session = scratchcommunication.Session.login(USERNAME, PASSWORD) | ||
|
||
security = scratchcommunication.security.Security.from_string(os.getenv("SCRATCH_SECURITY")) | ||
|
||
cloud_socket = session.create_cloud_socket( | ||
project_id = "884190099", | ||
security = security | ||
) | ||
|
||
with cloud_socket.listen(): | ||
while True: | ||
try: | ||
client, client_username = cloud_socket.accept() | ||
except TimeoutError: | ||
continue | ||
print(client_username + " connected!") | ||
|
||
client.send("Hello client!") |