Testing scripts for Rendering
In order to develop rendering you might need to read all messages it's giving. And / Or send to it messages manually. So these are 2 very simple terminal based scripts that will do it for you. Please read the code to before using.
This commit is contained in:
parent
145289db7a
commit
3b58c5151b
2 changed files with 60 additions and 0 deletions
36
network/read_messages.py
Normal file
36
network/read_messages.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
# GNU General Public License
|
||||
|
||||
# This script is for developers of VCStudio rendering. This will read any
|
||||
# message on 127.0.0.1 port 54545
|
||||
|
||||
import socket
|
||||
|
||||
UDP_IP = "127.0.0.1"
|
||||
UDP_PORT = 54545
|
||||
|
||||
|
||||
prev = ""
|
||||
|
||||
while True:
|
||||
|
||||
|
||||
try:
|
||||
|
||||
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
sock.bind((UDP_IP, UDP_PORT))
|
||||
sock.settimeout(0.05)
|
||||
|
||||
data, addr = sock.recvfrom(1024)
|
||||
data = data.decode('utf8')
|
||||
|
||||
if prev != str(data):
|
||||
print("<<< "+str(data))
|
||||
|
||||
prev = str(data)
|
||||
|
||||
sock.close()
|
||||
|
||||
except:
|
||||
pass
|
24
network/send_messages.py
Normal file
24
network/send_messages.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# GNU General Public License
|
||||
|
||||
# This script is for developers of VCStudio rendering. This will send any
|
||||
# message you type in the terminal to 127.0.0.1 port 54545
|
||||
|
||||
import socket
|
||||
import time
|
||||
|
||||
prev = ""
|
||||
|
||||
while True:
|
||||
message = input(">>> ")
|
||||
|
||||
if message == "exit":
|
||||
break
|
||||
|
||||
for i in range(500):
|
||||
cs1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
cs1.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
cs1.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||
|
||||
#message = "["+str(i)+"]TEST VCStudio rendering"
|
||||
cs1.sendto(bytes(message, 'utf-8'), ('127.0.0.1', 54545))
|
||||
#print(message)
|
Loading…
Reference in a new issue