Important: The information in this document is obsolete and should not be used for new development.
CyberStream
An object of class
- Superclasses
ODObject
- Subclasses
- none
CyberStream
downloads the data referenced by aCyberItem
object.Description
TheCyberStream
class is an abstract class that you can subclass and implement to provide downloading support for a particular service. A stream object interacts with a server to download the data referenced by a Cyberdog item, given its location. A Cyberdog display part uses a stream object to download the data referenced by its Cyberdog item.Cyberdog provides implemented
CyberStream
subclasses for some common protocols: HTTP, Gopher, and FTP. You can use any of these existingCyberStream
subclasses or create a newCyberStream
subclass to support a new network protocol.A stream subclass usually has a companion Cyberdog item subclass that references data on that type of server. For example, an object of the
WebItem
class (an implementedCyberItem
subclass supplied with Cyberdog) references data located on a web (HTTP) server. An object of the companionWebStream
class (an implementedCyberStream
subclass supplied with Cyberdog) interacts with the web server to download the data.If a stream is to be used to download the data referenced by a Cyberdog item, the Cyberdog item is responsible for creating a stream. A Cyberdog display part calls the
CyberItem::CreateCyberStream
method to create a new stream object initialized to download the data referenced by the Cyberdog item. The Cyberdog item performs any initialization necessary to communicate the address of its resources to the stream object.When a Cyberdog display part is ready to download the data referenced by its Cyberdog item, it calls the stream's
Open
method, which always returns immediately; however, a stream object may download data either asynchronously or synchronously. In either case, the display part checks the status of the download operation periodically by calling theGetStreamStatus
method, which returns a set of flags indicating the current status.A stream object allocates memory buffers to hold incoming data. If the stream has data (if the
kCDDataAvailable
flag is set totrue
), the display part can call the stream'sGetBuffer
method to retrieve a buffer. This scheme minimizes the repeated copying of data during the download process and allows the stream to proceed with the download operation instead of waiting for the first call toGetBuffer
. When it has finished using a buffer, the display part should call theReleaseBuffer
method to return the buffer to the stream object.There is no
Close
method in the stream interface; when the stream object detects that the download operation is complete (when thekCDDownloadComplete
flag is set totrue
), it closes the connection on its own.
GetStreamStatus
,GetBuffer
, andReleaseBuffer
are all synchronous methods; they return immediately no matter whether the stream object is downloading asynchronously or synchronously. For this reason, a stream object should not postpone the reading of data until the display part calls theGetBuffer
method. The stream should read the data on its own time and set thekCDDataAvailable
flag totrue
when data has been read successfully. A simple stream implementation might read data until its buffers are full whenOpen
is called, and then wheneverReleaseBuffer
is called.A simple stream implementation might also keep the
kCDBuffersAreLow
flag set totrue
at all times. To proceed with asynchronous downloading, the stream object needs memory to store the incoming data. To maximize stream performance, make sure that the stream always has memory available to store data as it comes in.Methods
This section presents summary descriptions of theCyberStream
methods grouped according to purpose, followed by detailed descriptions.Controlling a Stream
Managing Buffers
Open
- Opens this Cyberdog stream and initiates the downloading process.
Abort
- Terminates a download operation being performed by this Cyberdog stream.
Retrieving Stream Information
GetBuffer
- Retrieves a buffer from this Cyberdog stream.
ReleaseBuffer
- Releases a buffer to this Cyberdog stream.
GetLastModTime
- Retrieves the last modification time for the data in this Cyberdog stream.
GetStatusString
- Retrieves a string describing the current status of this Cyberdog stream.
GetStreamError
- Retrieves the first nontrivial error encountered by this Cyberdog stream.
GetStreamStatus
- Retrieves the current status flags for this Cyberdog stream.
GetTotalDataSize
- Retrieves the total size, in bytes, of the data available to be downloaded by this Cyberdog stream.
IsLastModTimeAvailable
- Tests whether the last modification time is available for data in this Cyberdog stream.
IsTotalDataSizeAvailable
- Tests whether the total size of this Cyberdog stream is available.
Methods
- Abort
- GetBuffer
- GetLastModTime
- GetStatusString
- GetStreamError
- GetStreamStatus
- GetTotalDataSize
- IsLastModTimeAvailable
- IsTotalDataSizeAvailable
- Open
- ReleaseBuffer