Skip to content
This repository was archived by the owner on Dec 20, 2021. It is now read-only.

Commit 7ff79c7

Browse files
committed
Async WebSocket Client example
1 parent 641662a commit 7ff79c7

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

examples/async/WebSocket Client.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class AClient(AWSSClient):
2+
async def on_friend_location(self, friend, world, location, instance):
3+
print("{} is now in {}.".format(friend.displayName, world.name))
4+
5+
async def on_friend_offline(self, friend):
6+
print("{} went offline.".format(friend.displayName))
7+
8+
async def on_friend_active(self, friend):
9+
print("{} is now {}.".format(friend.displayName, friend.state))
10+
11+
async def on_friend_online(self, friend):
12+
print("{} is now online.".format(friend.displayName))
13+
14+
async def on_notification(self, notification):
15+
print("Got a {} notification from {}.".format(notification.type, notification.senderUsername))
16+
17+
async def wait_loop(self):
18+
await self.login2fa(input("Username: "), input("Password: "), input("2FA Code: "), True)
19+
20+
while True:
21+
await asyncio.sleep(1)
22+
23+
def __init__(self):
24+
super().__init__()
25+
try:
26+
asyncio.get_event_loop().run_until_complete(self.wait_loop())
27+
except KeyboardInterrupt:
28+
asyncio.get_event_loop().run_until_complete(self.logout())
29+
30+
c = AClient()

0 commit comments

Comments
 (0)