Skip to content

Instantly share code, notes, and snippets.

@TURBODRIVER
Created February 23, 2025 10:25
Show Gist options
  • Save TURBODRIVER/6477703228c4dfa7e87e9c5ca00edc86 to your computer and use it in GitHub Desktop.
Save TURBODRIVER/6477703228c4dfa7e87e9c5ca00edc86 to your computer and use it in GitHub Desktop.
import json
import socket
HOST = '127.0.0.1'
PORT = 60069
DEVICE_NAME = 'This is my toy name' # Device personal name
DEVICE_MODEL = 'Super Device Ultra 2' # Device branding name
def run_sex_devices_listener():
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((HOST, PORT))
server_socket.listen(5)
while True:
conn, _ = server_socket.accept()
# Receive size of upcoming data in the next message
try:
data_size = int(conn.recv(10).decode('utf-8').strip())
except:
conn.close()
continue
# Receive all sent data with expected size
data = b''
while len(data) < data_size:
data_chunk = conn.recv(1024)
if not data_chunk:
break
data += data_chunk
if data:
# Process received json into dictionary
try:
data = data.decode('utf-8')
data = json.loads(data)
except:
conn.close()
continue
# All sent data contains a command, expected commands include
# "GetDevices" which expects a return message that contains a list of all involved sex devices names and models
# "Actions" which contains a list of actions for the involved sex devices
command = data.get('command', None)
# The "GetDevices" command is sent when a user is trying to connect to the server in the Sex Devices menu
# expecting to receive a list with at least one sex device name and model
# then informs the user that a connection has been established and displays the name and model
if command == "GetDevices":
conn.sendall(json.dumps({
'devices': [{
'device_name': DEVICE_NAME,
'device_model': DEVICE_MODEL,
}, ]
}).encode('utf-8'))
print("Sent sex devices info.")
# The "Actions" command is sent when a user performs interactions in-game that would cause sex devices to react
# every "Actions" command contains a list of actions in order, expected actions include
# "action" which is the type of action for a sex device (stop, vibrate, pump, rotate, finger, suck, thrust, depth, oscillate)
# "strength" which is the strength of the action from 0 to 100
# "duration" which is the duration of the action in milliseconds
# received actions can be processed and executed on however you want
elif command == "Actions":
actions = data.get('actions', ())
for action in actions:
print(action)
conn.close()
if __name__ == "__main__":
run_sex_devices_listener()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
OSZAR »