Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 internal void SendAgent(Agent agent, string target, int port)
 {
     _agents.Remove(agent);
     _agentServer.Send(target, port, agent);
 }
Esempio n. 3
0
 public void Register(Agent agent)
 {
     if (agent.Sent) throw new Exception("Zombie");
     _agents.Add(agent);
     new Thread(() => agent.Resume(this)).Start();
 }
Esempio n. 4
0
 public void PlanTravel(Agent agent, string target, int port)
 {
     agent.TravelTo(target, port);
 }