Skip to content
Snippets Groups Projects
ServerActionJoin.java 903 B
Newer Older
Michael Kmoch's avatar
Michael Kmoch committed
package fucoin.actions.join;

import akka.actor.ActorRef;
import akka.actor.UntypedActorContext;
import fucoin.actions.transaction.ActionInvokeDistributedCommitedTransfer;
import fucoin.actions.transaction.SuperVisorAction;
Michael Kmoch's avatar
Michael Kmoch committed

public class ServerActionJoin extends SuperVisorAction {
Michael Kmoch's avatar
Michael Kmoch committed

    public ServerActionJoin(String name) {
        this.name = name;
    }
Michael Kmoch's avatar
Michael Kmoch committed

    @Override
    protected void onAction(ActorRef sender, ActorRef self,
                            UntypedActorContext context, SuperVisorImpl node) {
        ActionJoinAnswer aja = new ActionJoinAnswer();
        aja.someNeighbors.putAll(node.getKnownNeighbors());
        sender.tell(aja, self);
        node.addKnownNeighbor(name, sender);
        self.tell(
                new ActionInvokeDistributedCommitedTransfer(self, sender, 100),
                sender);
    }
Michael Kmoch's avatar
Michael Kmoch committed
}