com.google.bitcoin.protocols.channels
Interface IPaymentChannelClient.ClientConnection

Enclosing interface:
IPaymentChannelClient

public static interface IPaymentChannelClient.ClientConnection

Implements the connection between this client and the server, providing an interface which allows messages to be sent to the server, requests for the connection to the server to be closed, and a callback which occurs when the channel is fully open.


Method Summary
 void channelOpen(boolean wasInitiated)
          Indicates the channel has been successfully opened and PaymentChannelClient.incrementPayment(java.math.BigInteger) may be called at will.
 void destroyConnection(PaymentChannelCloseException.CloseReason reason)
          Requests that the connection to the server be closed.
 void sendToServer(Protos.TwoWayChannelMessage msg)
          Requests that the given message be sent to the server.
 

Method Detail

sendToServer

void sendToServer(Protos.TwoWayChannelMessage msg)

Requests that the given message be sent to the server. There are no blocking requirements for this method, however the order of messages must be preserved.

If the send fails, no exception should be thrown, however PaymentChannelClient.connectionClosed() should be called immediately. In the case of messages which are a part of initialization, initialization will simply fail and the refund transaction will be broadcasted when it unlocks (if necessary). In the case of a payment message, the payment will be lost however if the channel is resumed it will begin again from the channel value after the failed payment.

Called while holding a lock on the PaymentChannelClient object - be careful about reentrancy


destroyConnection

void destroyConnection(PaymentChannelCloseException.CloseReason reason)

Requests that the connection to the server be closed. For stateless protocols, note that after this call, no more messages should be received from the server and this object is no longer usable. A PaymentChannelClient.connectionClosed() event should be generated immediately after this call.

Called while holding a lock on the PaymentChannelClient object - be careful about reentrancy

Parameters:
reason - The reason for the closure, see the individual values for more details. It is usually safe to ignore this and treat any value below PaymentChannelCloseException.CloseReason.CLIENT_REQUESTED_CLOSE as "unrecoverable error" and all others as "try again once and see if it works then"

channelOpen

void channelOpen(boolean wasInitiated)

Indicates the channel has been successfully opened and PaymentChannelClient.incrementPayment(java.math.BigInteger) may be called at will.

Called while holding a lock on the PaymentChannelClient object - be careful about reentrancy

Parameters:
wasInitiated - If true, the channel is newly opened. If false, it was resumed.


Copyright © 2014. All rights reserved.