public void Send(string address, int port, Agent agent) { var stream = new MemoryStream(); var formatter = new BinaryFormatter(); formatter.Serialize(stream, agent); var client = new TcpClient(address, port); var ns = client.GetStream(); Console.WriteLine("Log: Sending agent: " + agent); var bytes = stream.ToArray(); ns.Write(bytes, 0, bytes.Length); }
internal void SendAgent(Agent agent, string target, int port) { _agents.Remove(agent); _agentServer.Send(target, port, agent); }
public void Register(Agent agent) { if (agent.Sent) throw new Exception("Zombie"); _agents.Add(agent); new Thread(() => agent.Resume(this)).Start(); }
public void PlanTravel(Agent agent, string target, int port) { agent.TravelTo(target, port); }