Skip to content

Commit

Permalink
Made it so the pulsoidListen() can stop
Browse files Browse the repository at this point in the history
  • Loading branch information
Lioncat6 committed Jul 5, 2023
1 parent 7d28d9e commit 21a3a90
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions osc-chat-tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import requests


if not os.path.isfile('please-do-not-delete.txt'):
"""os.system("pip install python-osc")
os.system("pip install argparse")
Expand Down Expand Up @@ -95,6 +96,7 @@
voiceVolume = 0
isUsingEarmuffs = False


def afk_handler(unused_address, args):
global isAfk
isAfk = args
Expand Down Expand Up @@ -995,16 +997,22 @@ def hrConnectionThread():
if not hrConnected:
try:
ws = create_connection("wss://dev.pulsoid.net/api/v1/data/real_time?access_token="+pulsoidToken+"&response_mode=text_plain_only_heart_rate")
ws.settimeout(1) # Set a timeout of 1 second so the thread stops
hrConnected = True
def pulsoidListen():
global heartRate
for event in ws:
heartRate = event
client.send_message("/avatar/parameters/isHRActive", True)
client.send_message("/avatar/parameters/isHRConnected", True)
client.send_message("/avatar/parameters/HR", int(event))
if not run or not hrConnected:
break
global heartRate
while True:
try:
event = ws.recv()
heartRate = event
client.send_message("/avatar/parameters/isHRActive", True)
client.send_message("/avatar/parameters/isHRConnected", True)
client.send_message("/avatar/parameters/HR", int(event))
except:
pass
if not run or not hrConnected:
break

pulsoidListenThread = Thread(target=pulsoidListen)
pulsoidListenThread.start()
def blinkHR():
Expand Down

0 comments on commit 21a3a90

Please sign in to comment.