This interface is deprecated.
UseChannelClient.Channel
.
A channel created through
ChannelApi.openChannel(GoogleApiClient, String, String)
.
The implementation of this interface is parcelable and immutable, and implements
reasonableObject.equals(Object)
andObject.hashCode()
methods, so can be used in collections.
Nested Class Summary
interface | Channel.GetInputStreamResult | This interface is deprecated. See
ChannelClient.getInputStream(ChannelClient.Channel) . |
|
interface | Channel.GetOutputStreamResult | This interface is deprecated. See
ChannelClient.getOutputStream(ChannelClient.Channel) . |
Inherited Constant Summary
Public Method Summary
abstractPendingResult<Status> |
addListener(GoogleApiClient
client,
ChannelApi.ChannelListenerlistener)
Registers a listener to be notified of events for this channel.
|
abstractPendingResult<Status> |
close(GoogleApiClient
client, int errorCode)
Closes this channel, passing an application-defined error code to the remote
node.
|
abstractPendingResult<Status> | |
abstractPendingResult<Channel.GetInputStreamResult> |
getInputStream(GoogleApiClient
client)
Opens the input side of the channel to receive data from the remote node.
|
abstractString |
getNodeId()
Returns the node ID of the node on the other side of the channel.
|
abstractPendingResult<Channel.GetOutputStreamResult> |
getOutputStream(GoogleApiClient
client)
Opens the output side of the channel to send data to the remote node.
|
abstractString |
getPath()
Returns the path that was used to open the channel.
|
abstractPendingResult<Status> |
receiveFile(GoogleApiClient
client,Uri
uri, boolean append)
Reads input from this channel into a file.
|
abstractPendingResult<Status> |
removeListener(GoogleApiClient
client,
ChannelApi.ChannelListenerlistener)
Removes a listener which was previously added through
addListener(GoogleApiClient, ChannelApi.ChannelListener) .
|
abstractPendingResult<Status> | |
abstractPendingResult<Status> |
sendFile(GoogleApiClient
client,Uri
uri, long startOffset, long length)
Reads from a file into the output side of the channel.
|
Inherited Method Summary
Public Methods
public abstractPendingResult<Status> addListener(GoogleApiClient client,ChannelApi.ChannelListener listener)
Registers a listener to be notified of events for this channel. This is the same as
ChannelApi.addListener(GoogleApiClient, ChannelApi.ChannelListener)
,but the
listener will only be notified of events for this channel. The listener will not
receive
ChannelApi.ChannelListener.onChannelOpened(Channel)
events.
Calls to this method should balanced with
removeListener(GoogleApiClient, ChannelApi.ChannelListener)
to avoid leaking
resources.
Listener events will be called on the main thread, or the handler specified on
client
when it was built (using
GoogleApiClient.Builder.setHandler(Handler)
).
Parameters
client | a connected client |
---|---|
listener | a listener which will be notified of changes to the specified stream |
public abstractPendingResult<Status> close(GoogleApiClient client, int errorCode)
Closes this channel, passing an application-defined error code to the remote node.
The error code will be passed to
ChannelApi.ChannelListener.onChannelClosed(Channel, int, int)
,and will
cause remote reads and writes to the channel to fail withChannelIOException
.
TheInputStream
and
OutputStream
returned from
getInputStream(GoogleApiClient)
or
getOutputStream(GoogleApiClient)
should be closed prior to calling this
method. If they are not, both streams will throwChannelIOException
on the next read or write operation.
errorCode == 0
is used to indicate that no error occurred.
Parameters
client | a connected client |
---|---|
errorCode | an app-defined error code to pass to the remote node |
public abstractPendingResult<Status> close(GoogleApiClient client)
Closes this channel, making any future operations on it invalid.
This method behaves like
close(GoogleApiClient, int)
,witherrorCode == 0
.
Parameters
client | a connected client |
---|
public abstractPendingResult<Channel.GetInputStreamResult> getInputStream(GoogleApiClient client)
Opens the input side of the channel to receive data from the remote node. Methods on
the returned input stream may throwChannelIOException
.
See
GetInputStreamResult.getInputStream()
This method should only be used once on any channel, and once it was called,
receiveFile(GoogleApiClient, Uri, boolean)
cannot be used.
Parameters
client | a connected client |
---|
public abstractStringgetNodeId()
Returns the node ID of the node on the other side of the channel.
public abstractPendingResult<Channel.GetOutputStreamResult> getOutputStream(GoogleApiClient client)
Opens the output side of the channel to send data to the remote node. Methods on the
returned output stream may throwChannelIOException
.
See
GetOutputStreamResult.getOutputStream()
This method should only be used once on any channel, and once it was called,
sendFile(GoogleApiClient, Uri, long, long)
cannot be used.
Parameters
client | a connected client |
---|
public abstractStringgetPath()
Returns the path that was used to open the channel.
public abstractPendingResult<Status> receiveFile(GoogleApiClient client,Uriuri, boolean append)
Reads input from this channel into a file. This is equivalent to calling
getInputStream(GoogleApiClient)
,reading from the input stream and writing
it to a file, but is implemented more efficiently. Writing to the file will be done in
a background process owned by Google Play Services.
This method should only be used once on any channel, and once it was called,
getInputStream(GoogleApiClient)
cannot be used. The channel should not be
immediately closed after calling this method. To be notified when the file is ready,
install aChannelApi.ChannelListener
,
with an implementation of
ChannelApi.ChannelListener.onInputClosed(Channel, int, int)
.
Parameters
client | a connected client |
---|---|
uri | URI of the file into which data should be written. This should be a {@linkplain Uri#fromFile(java.io.File) file URI} for a file which is accessible to the current process for writing. |
append | if true, data from the channel will be appended to the file, instead of overwriting it. |
public abstractPendingResult<Status> removeListener(GoogleApiClient client,ChannelApi.ChannelListener listener)
Removes a listener which was previously added through
addListener(GoogleApiClient, ChannelApi.ChannelListener)
.
Parameters
client | a connected client |
---|---|
listener | a listener which was added using
addListener(GoogleApiClient, ChannelApi.ChannelListener) |
public abstractPendingResult<Status> sendFile(GoogleApiClient client,Uri uri)
Reads from a file into the output side of the channel. This is equivalent to calling
getOutputStream(GoogleApiClient)
,reading from a file and writing into the
OutputStream
,
but is implemented more efficiently. Reading from the file will be done in a background
process owned by Google Play Services.
This method should only be used once on any channel, and once it was called,
getOutputStream(GoogleApiClient)
cannot be used. The channel should not be
immediately closed after calling this method. To be notified when the file has been
sent, install aChannelApi.ChannelListener
,
with an implementation of
ChannelApi.ChannelListener.onOutputClosed(Channel, int, int)
.
This method is identical to calling
sendFile(GoogleApiClient, Uri, long, long)
withoffset == 0
and
length == -1
.
Parameters
client | a connected client |
---|---|
uri | URI of the file from which data should be read. This should be a {@linkplain Uri#fromFile(java.io.File) file URI} for a file which is accessible to the current process for reading. |
public abstractPendingResult<Status> sendFile(GoogleApiClient client,Uriuri, long startOffset, long length)
Reads from a file into the output side of the channel. This is equivalent to calling
getOutputStream(GoogleApiClient)
,reading from a file and writing into the
OutputStream
,
but is implemented more efficiently. Reading from the file will be done in a background
process owned by Google Play Services.
This method should only be used once on any channel, and once it was called,
getOutputStream(GoogleApiClient)
cannot be used. The channel should not be
immediately closed after calling this method. To be notified when the file has been
sent, install aChannelApi.ChannelListener
,
with an implementation of
ChannelApi.ChannelListener.onOutputClosed(Channel, int, int)
.
Parameters
client | a connected client |
---|---|
uri | URI of the file from which data should be read. This should be a {@linkplain Uri#fromFile(java.io.File) file URI} for a file which is accessible to the current process for reading. |
startOffset | byte offset from which to start reading |
length | maximum number of bytes to read from the file, or-1 if the file
should be read to its end. If the file doesn't contain enough bytes to reach
length ,fewer bytes will be read. |