# GNU General Public License

# This script is for developers of VCStudio. This one is sending test messages.

import socket
import time
import sys

# Fisrt we need to know what mode are we testing.

print(" VCStudio Send Test Messages.")
print(" Modes: r [Render], m [Multiuser]")

if len(sys.argv) > 2:
    mode = sys.argv[2]
    print("Mode: "+mode)
    
else:
    mode = input("Mode: ")

import socket

if mode == "r":
    UDP_IP = "127.0.0.1"
    UDP_PORT = 54545
    
elif mode == "m":
    UDP_IP = "255.255.255.255"
    UDP_PORT = 54545
    
else:
    print("There is no mode: "+mode)
    exit()


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'), (UDP_IP, UDP_PORT))
        #print(message)
