protected void handleDisconnect(final DisconnectMessage incomingMessage) { if (logger.isDebugEnabled()) logger.debug("processing message:" + incomingMessage.toString()); if (incomingMessage.stopUploading()) { // this peer won't upload anymore to the sender of the message (peer may be added again) this.videoSignaling.disconnectPeer( incomingMessage.getSender(), incomingMessage.getSegmentIdentifier()); } if (incomingMessage.stopDownloading()) { // this peer won't download anymore from the sender of the message (peer may be added again) this.tuner.disconnectPeer( incomingMessage.getSender(), incomingMessage.getSegmentIdentifier()); // this.tuner.getNeighborList().lookForCandidates(incomingMessage.getSegmentIdentifier()); } }
protected void processMessage(AbstractMessage incomingMessage) { if (incomingMessage.isProcessed() && !(incomingMessage instanceof HaveMessage || incomingMessage instanceof BlockReplyMessage)) return; AbstractMessage replyMessage = null; // USM if (incomingMessage instanceof SubscribeMessage) { replyMessage = this.handleSubscribe((SubscribeMessage) incomingMessage); } else if (incomingMessage instanceof InterestedMessage) { replyMessage = this.handleInterested((InterestedMessage) incomingMessage); } else if (incomingMessage instanceof DisconnectMessage) { DisconnectMessage disconnectMessage = (DisconnectMessage) incomingMessage; if (disconnectMessage.stopUploading()) this.handleDisconnect(disconnectMessage); // TUNER if (disconnectMessage.stopDownloading()) this.handleDisconnect(disconnectMessage); } else if (incomingMessage instanceof HaveMessage) { this.handleHave((HaveMessage) incomingMessage); } else if (incomingMessage instanceof SubscribedMessage) { this.handleSubscribed((SubscribedMessage) incomingMessage); } else if (incomingMessage instanceof QueuedMessage) { this.handleQueued((QueuedMessage) incomingMessage); } else if (incomingMessage instanceof GrantedMessage) { this.handleGranted((GrantedMessage) incomingMessage); } else if (incomingMessage instanceof BlockReplyMessage) { this.handleBlockReply((BlockReplyMessage) incomingMessage); } else if (incomingMessage instanceof PeerSuggestionMessage) { this.handlePeerSuggestion((PeerSuggestionMessage) incomingMessage); } else { logger.warn("Unknown message received, not processing (" + incomingMessage + ")"); } incomingMessage.setReplyMessage(replyMessage, incomingMessage.getSender()); }