@Override public void destroyConnection(PaymentChannelCloseException.CloseReason reason) { if (closeReason != null) closeReason = reason; socketProtobufHandler.closeConnection(); }
/** * Disconnects the network connection but doesn't request the server to settle the channel first (literally just * unplugs the network socket and marks the stored channel state as inactive). */ public void disconnectWithoutSettlement() { wireParser.closeConnection(); } }
@Override public void destroyConnection(PaymentChannelCloseException.CloseReason reason) { if (closeReason != null) closeReason = reason; socketProtobufHandler.closeConnection(); }
@Override public void destroyConnection(PaymentChannelCloseException.CloseReason reason) { if (closeReason != null) closeReason = reason; socketProtobufHandler.closeConnection(); }
/** * Disconnects the network connection but doesn't request the server to settle the channel first (literally just * unplugs the network socket and marks the stored channel state as inactive). */ public void disconnectWithoutSettlement() { wireParser.closeConnection(); } }
/** * Disconnects the network connection but doesn't request the server to settle the channel first (literally just * unplugs the network socket and marks the stored channel state as inactive). */ public void disconnectWithoutSettlement() { wireParser.closeConnection(); } }
@Override public void destroyConnection(PaymentChannelCloseException.CloseReason reason) { if (closeReason != null) closeReason = reason; socketProtobufHandler.closeConnection(); }
/** * Disconnects the network connection but doesn't request the server to settle the channel first (literally just * unplugs the network socket and marks the stored channel state as inactive). */ public void disconnectWithoutSettlement() { wireParser.closeConnection(); } }
@Override protected void timeoutOccurred() { log.warn("Timeout occurred for " + handler); closeConnection(); }
@Override protected void timeoutOccurred() { log.warn("Timeout occurred for " + handler); closeConnection(); }
@Override protected void timeoutOccurred() { log.warn("Timeout occurred for " + handler); closeConnection(); }
@Override protected void timeoutOccurred() { log.warn("Timeout occurred for " + handler); closeConnection(); }
@Override public void destroyConnection(PaymentChannelCloseException.CloseReason reason) { channelOpenFuture.setException(new PaymentChannelCloseException("Payment channel client requested that the connection be closed: " + reason, reason)); wireParser.closeConnection(); }
@Override public void destroyConnection(PaymentChannelCloseException.CloseReason reason) { channelOpenFuture.setException(new PaymentChannelCloseException("Payment channel client requested that the connection be closed: " + reason, reason)); wireParser.closeConnection(); }
@Override public void destroyConnection(PaymentChannelCloseException.CloseReason reason) { channelOpenFuture.setException(new PaymentChannelCloseException("Payment channel client requested that the connection be closed: " + reason, reason)); wireParser.closeConnection(); }
@Override public void destroyConnection(PaymentChannelCloseException.CloseReason reason) { channelOpenFuture.setException(new PaymentChannelCloseException("Payment channel client requested that the connection be closed: " + reason, reason)); wireParser.closeConnection(); }
/** * <p>Writes the given message to the other side of the connection, prefixing it with the proper 4-byte prefix.</p> * * <p>Provides a write-order guarantee.</p> * * @throws IllegalStateException If the encoded message is larger than the maximum message size. */ public void write(MessageType msg) throws IllegalStateException { byte[] messageBytes = msg.toByteArray(); checkState(messageBytes.length <= maxMessageSize); byte[] messageLength = new byte[4]; Utils.uint32ToByteArrayBE(messageBytes.length, messageLength, 0); try { MessageWriteTarget target = writeTarget.get(); target.writeBytes(messageLength); target.writeBytes(messageBytes); } catch (IOException e) { closeConnection(); } } }
/** * <p>Writes the given message to the other side of the connection, prefixing it with the proper 4-byte prefix.</p> * * <p>Provides a write-order guarantee.</p> * * @throws IllegalStateException If the encoded message is larger than the maximum message size. */ public void write(MessageType msg) throws IllegalStateException { byte[] messageBytes = msg.toByteArray(); checkState(messageBytes.length <= maxMessageSize); byte[] messageLength = new byte[4]; Utils.uint32ToByteArrayBE(messageBytes.length, messageLength, 0); try { MessageWriteTarget target = writeTarget.get(); target.writeBytes(messageLength); target.writeBytes(messageBytes); } catch (IOException e) { closeConnection(); } } }
/** * <p>Writes the given message to the other side of the connection, prefixing it with the proper 4-byte prefix.</p> * * <p>Provides a write-order guarantee.</p> * * @throws IllegalStateException If the encoded message is larger than the maximum message size. */ public void write(MessageType msg) throws IllegalStateException { byte[] messageBytes = msg.toByteArray(); checkState(messageBytes.length <= maxMessageSize); byte[] messageLength = new byte[4]; Utils.uint32ToByteArrayBE(messageBytes.length, messageLength, 0); try { MessageWriteTarget target = writeTarget.get(); target.writeBytes(messageLength); target.writeBytes(messageBytes); } catch (IOException e) { closeConnection(); } } }
/** * <p>Closes the channel with the client (will generate a * {@link ServerConnectionEventHandler#channelClosed(PaymentChannelCloseException.CloseReason)} event)</p> * * <p>Note that this does <i>NOT</i> actually broadcast the most recent payment transaction, which will be triggered * automatically when the channel times out by the {@link StoredPaymentChannelServerStates}, or manually by calling * {@link StoredPaymentChannelServerStates#closeChannel(StoredServerChannel)} with the channel returned by * {@link StoredPaymentChannelServerStates#getChannel(org.bitcoinj.core.Sha256Hash)} with the id provided in * {@link ServerConnectionEventHandler#channelOpen(org.bitcoinj.core.Sha256Hash)}</p> */ @SuppressWarnings("unchecked") // The warning 'unchecked call to write(MessageType)' being suppressed here comes from the build() // formally returning MessageLite-derived class that cannot be statically guaranteed to be the same MessageType // that is used in connectionChannel. protected final synchronized void closeChannel() { if (connectionChannel == null) throw new IllegalStateException("Channel is not fully initialized/has already been closed"); connectionChannel.write(Protos.TwoWayChannelMessage.newBuilder() .setType(Protos.TwoWayChannelMessage.MessageType.CLOSE) .build()); connectionChannel.closeConnection(); }