private static ClientWorker[] CreateRemoteClients(int count) { var serializer = new PacketSerializer( new PacketSerializerBase.Data( new ProtoBufMessageSerializer(TypeModel.Create()), new TypeAliasTable())); var communicators = new Communicator[count]; for (int i = 0; i < count; i++) { var communicator = new Communicator(LogManager.GetLogger("Communicator"), new IPEndPoint(IPAddress.Loopback, 8081), _ => new TcpConnection(serializer, LogManager.GetLogger("Connection"))); communicator.Start(); communicators[i] = communicator; } for (int i = 0; i < 100; i++) { Thread.Sleep(10); var connectedCount = communicators.Count(c => c.State == Communicator.StateType.Connected); if (connectedCount == count) { break; } var closedCount = communicators.Count(c => c.State == Communicator.StateType.Stopped); if (closedCount > 0) { throw new Exception("Connection closed!"); } } var clients = new ClientWorker[count]; for (int i = 0; i < count; i++) { var requestWaiter = new SlimTaskRequestWaiter(communicators[i]); var server = new ServerRef(new SlimActorRef(1), requestWaiter, null); clients[i] = new ClientWorker(server); } return(clients); }
public ClientWorker(ServerRef server) { _server = server; }
public ClientActor(IActorRef server) { _server = new ServerRef(server, this, null); }