private void ProcessRandomMsg(RandomMsg msg) { // Pravilo Lamporovog sata LamportClock = Math.Max(msg.TimeStampMsg.LamportTime, LamportClock) + 1; string mojeIme = Self.Path.Name; TimeStampMsg timeStampPoruka = new TimeStampMsg(LamportClock, "Hello from " + mojeIme); _logger.Tell(new Log(mojeIme, timeStampPoruka)); }
private void Loop(List <IActorRef> others, int sleep) { IActorRef actor = SelectOne(others); // Pravilo Lamportovog sata LamportClock++; // Ime actora mozemo dohvatiti uz pomoc putanje string mojeIme = Self.Path.Name; TimeStampMsg timeStampPoruka = new TimeStampMsg(LamportClock, "Hello from " + mojeIme); RandomMsg randommsg = new RandomMsg(_rnd.Next(2000), timeStampPoruka); actor.Tell(randommsg); Thread.Sleep(_rnd.Next(100)); // Posaljimo poruku loggeru da logira trenutno stanje _logger.Tell(new Log(mojeIme, timeStampPoruka)); // Pricekat cemo "sleep" prije nego posaljemo novu poruku Context.System.Scheduler.ScheduleTellOnce(TimeSpan.FromMilliseconds(sleep), Self, new Loop(), Self); }