MCPcopy Create free account
hub / github.com/JoshuaPostel/texaform / Agent

Class Agent

python/agent.py:11–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class Agent:
12
13 # TODO post_init() method to clean up child classes
14 def __init__(self, port: int, location: Point):
15 self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
16 self.socket.connect((HOST, port))
17 self.location: Point = location
18
19 def send(self, msg: str) -> str:
20 self.socket.sendall(str.encode(msg + ";"))
21 # TODO move to logging setup
22 #print(f"sent: {msg}")
23 buffer = b""
24 while b";" not in buffer:
25 data = self.socket.recv(32)
26 buffer += data
27 response = buffer.decode("utf-8")
28 # strip the trailing ;
29 response = response[:-1]
30 # TODO move to logging setup
31 #print(f"recv: {response}")
32 return response
33
34 def kind(self) -> str:
35 response = self.send("KIND")
36 name = response.split()[1]
37 return name
38
39

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected