[enhancement] Simple socket client for custom XML data on the FreeTAKServer
Opened this issue · 0 comments
Cale-Torino commented
Hi, can we add a simple socket client feature to the connect
page on the FreeTAKServer
?
Example use such as a user testing XML TCP posts to the server to see if their code is working also for testing behaviour by sending custom XML code.
Python Example:
import socket
UDP_IP = '10.0.0.60' #127.0.0.1
UDP_PORT = 8087 #5005
MESSAGE = '<?xml version="1.0"?><event version="2.0" uid="TestSign" type="a-f-G-U-C" how="m-g" start="2021-03-30T10:31:41.042Z" time="2021-03-30T17:31:41.042Z" stale="2021-03-30T17:37:56.042Z"><detail><contact callsign="TestSign"/><__group name="Blue" role="Team Lead" /></detail><point le="9999999.0" ce="5.0" hae="217.88824764640728" lon="-0.665562" lat="54.019611" /></event>'
# Create a socket (SOCK_STREAM means a TCP socket)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
# Connect to server and send data
sock.connect((UDP_IP, UDP_PORT))
sock.sendall(bytes(MESSAGE + "\n", "utf-8"))
# Receive data from the server and shut down
received = str(sock.recv(1024), "utf-8")
# Print and handle data how you want
print("Sent: {}".format(MESSAGE))
print('\n')
print("Received: {}".format(received))
Features can be added as it grows and having this built in will add value to the user/testers experience.
Card Example: