@Override public void init() throws IOException { super.init(); send(new GetUserList()); send(new GetUserInfo()); send(new GetMyExternalIp()); if (direction == Direction.OUT && getRemoteFriend().isNewlyDiscoveredFriend()) { core.queNeedsUserInteraction(new NewFriendConnectedUserInteraction(remoteUserGUID)); getRemoteFriend().setNewlyDiscoveredFriend(false); } }
public void signalBlockComplete(int blockNumber) throws IOException { signalBlockCompleteCounter++; if (signalBlockCompleteCounter > SEND_BLOCKMASK_UPDATE_INTERVAL_IN_BLOCKS) { signalBlockCompleteCounter = 0; BlockFile bf = storage.getBlockFile(fd.getRootHash()); if (bf == null) { return; } List<Friend> list = manager.getFriendsInterestedIn(root); if (list != null) { for (Friend f : list) { FriendConnection fc = f.getFriendConnection(); if (fc != null) { if (T.t) { T.info( "Friend " + f + " is interested in file " + root + ". Sending updated block mask to him."); } fc.send(new BlockMaskResult(root, bf.getBlockMask())); } } } } }
public void route(int dstGuid, RPC rpc) throws IOException { Friend f = netMan.getFriendManager().getFriend(dstGuid); if (f != null && f.getFriendConnection() != null) { if (T.t) { T.info("Rerouting package to friend"); } f.getFriendConnection().send(rpc); } else { // note that one of our friends COULD actually be a closer Route to the destination. But this // way we send // the rpc the same way back as be got it. No biggie probably. rpc.init(this); Packet p = createRPCPacket(rpc); send(new Route(netMan.getFriendManager().getMyGUID(), dstGuid, p)); } }
public void send(int dstGuid, RPC rpc) throws IOException { if (dstGuid != getRemoteUserGUID()) { if (T.t) { T.debug("Rerouting package " + rpc + " to " + dstGuid); } route(dstGuid, rpc); } else { if (!rpc.isInitialized()) { rpc.init( this); // under certain conditions a rpc can be reused and sent a second time - then // it's the first init call that counts. Don't make it twice. } Packet p = createRPCPacket(rpc); if (T.t) { T.debug("--> Sending " + rpc + " (" + p.getPos() + " bytes) to " + getRemoteFriend()); } send(p); } }
public void broadcast(short msgId, RPC rpc) throws IOException { rpc.init(this); Packet p = createRPCPacket(rpc); send(new Broadcast(netMan.getFriendManager().getMyGUID(), msgId, p)); }
public void send(RPC rpc) throws IOException { send(getRemoteUserGUID(), rpc); signalSent(rpc); }