/** * Replaces the current channel with the new one. * The old channel (if any) will be stopped and the new channel started. */ public void setChannel(Channel channel) throws GondolaException { channel.start(); if (this.channel != null) { this.channel.stop(); } this.channel = channel; }
public void start() throws GondolaException { if (threads.size() > 0) { throw new IllegalStateException("start() can only be called once"); } if (channel == null) { // Peer is not a slave so create a channel to remote member channel = gondola.getNetwork().createChannel(cmember.memberId, peerId); } channel.start(); reset(); // Start local threads threads.add(new Receiver()); threads.add(new Backfiller()); threads.add(new Sender()); threads.forEach(t -> t.start()); }