ZSDK_API  1.5.1049
 All Classes Functions Enumerations Enumerator Properties Pages
<ZebraPrinterConnection> Protocol Referenceabstract

A connection to a Zebra printer. More...

#import <ZebraPrinterConnection.h>

Inheritance diagram for <ZebraPrinterConnection>:
MfiBtPrinterConnection TcpPrinterConnection

Instance Methods

(NSString *) - toString
 See the classes which implement this method for the format of the description string.
 
(NSInteger) - getMaxTimeoutForRead
 Returns the maximum time, in milliseconds, to wait for any data to be received.
 
(NSInteger) - getTimeToWaitForMoreData
 Returns the maximum time, in milliseconds, to wait between reads after the initial read.
 
(void) - setMaxTimeoutForRead:
 Set the maximum time, in milliseconds, to wait for any data to be received.
 
(void) - setTimeToWaitForMoreData:
 Set the maximum time, in milliseconds, to wait in-between reads after the initial read.
 
(BOOL) - isConnected
 Returns YES if the connection is open.
 
(BOOL) - open
 Opens the connection to a device.
 
(void) - close
 Closes this connection and releases any system resources associated with the connection.
 
(NSInteger) - write:error:
 Writes the number of bytes from data to the connection.
 
(NSInteger) - write:withOffset:andWithLength:error:
 Writes length bytes from data starting at offset.
 
(NSInteger) - writeStream:error:
 Writes all available bytes from the data source to the connection.
 
(NSData *) - read:
 Reads all the available data from the connection.
 
(void) - read:error:
 Reads all the available data from the connection and write it to destinationStream.
 
(NSString *) - getSimpleConnectionName
 Return a human-readable description of the connection.
 
(BOOL) - hasBytesAvailable
 Returns YES if at least one byte is available for reading from this connection.
 
(void) - waitForData:
 Causes the currently executing thread to sleep until hasBytesAvailable equals YES, or for a maximum of maxTimeout milliseconds.
 
(NSData *) - sendAndWaitForResponse:withResponseValidator:withError:
 Sends data and returns the response data.
 
(NSData *) - sendAndWaitForResponse:withMaxTimeoutForRead:andWithTimeToWaitForMoreData:withResponseValidator:andWithError:
 Sends data and returns the response data.
 

Detailed Description

A connection to a Zebra printer.

Method Documentation

- (void) close

Closes this connection and releases any system resources associated with the connection.

If the connection is already closed then invoking this method has no effect.

- (NSInteger) getMaxTimeoutForRead

Returns the maximum time, in milliseconds, to wait for any data to be received.

Returns
The maximum time, in milliseconds, to wait for any data to be received.
- (NSString *) getSimpleConnectionName

Return a human-readable description of the connection.

Returns
a human-readable description of the connection.
- (NSInteger) getTimeToWaitForMoreData

Returns the maximum time, in milliseconds, to wait between reads after the initial read.

Returns
The maximum time, in milliseconds, to wait between reads after the initial read.
- (BOOL) hasBytesAvailable

Returns YES if at least one byte is available for reading from this connection.

Returns
YES if there is data avaiilable.
- (BOOL) isConnected

Returns YES if the connection is open.

Returns
YES if this connection is open.
- (BOOL) open

Opens the connection to a device.

If the open method is called on an open connection this call is ignored. When a handle to the connection is no longer needed, call close to free up system resources.

Returns
NO if the connection cannot be established.
- (NSData *) read: (NSError **)  error

Reads all the available data from the connection.

This call is non-blocking.

Parameters
errorWill be set to the error that occured.
Returns
The bytes read from the connection or nil if an error occurred.
- (void) read: (NSOutputStream *)  destinationStream
error: (NSError **)  error 

Reads all the available data from the connection and write it to destinationStream.

This call is non-blocking.

Parameters
destinationStreamOutput stream to recive the data read from the connection.
errorWill be set to the error that occured.
Returns
The bytes read from the connection or nil if an error occurred.
- (NSData*) sendAndWaitForResponse: (NSData *)  data
withMaxTimeoutForRead: (NSInteger)  maxTimeoutForRead
andWithTimeToWaitForMoreData: (NSInteger)  timeToWaitForMoreData
withResponseValidator: (id< ResponseValidator, NSObject >)  validator
andWithError: (NSError **)  error 

Sends data and returns the response data.

The software returns immediately if the response data received contains terminator. The connection must be open before this method is called. If sendAndWaitForResponse is called when a connection is closed, a ConnectionException is thrown.

Parameters
databyte array of data to send
maxTimeoutForReadThe maximum time, in milliseconds, to wait for the initial response to be received. If no data is received during this time, the function returns a zero length array.
timeToWaitForMoreDataAfter the initial response, if no data is received for this period of time, the input is considered complete and the method returns.
validatorIf the response is valid, the input is considered complete and the method returns. May be used to avoid waiting for more data when the response is always terminated with a known string. Use null if no validator is desired.
errorWill be set to the error that occured.
Returns
received data
- (NSData*) sendAndWaitForResponse: (NSData *)  data
withResponseValidator: (id< ResponseValidator, NSObject >)  validator
withError: (NSError **)  error 

Sends data and returns the response data.

The software returns immediately if the data received contains terminator. The connection must be open before this method is called. If sendAndWaitForResponse is called when a connection is closed, a ConnectionException is thrown.

Parameters
databyte array of data to send
validatorIf the response is valid, the input is considered complete and the method returns. May be used to avoid waiting for more data when the response is always terminated with a known string. Use null if no validator is desired.
errorWill be set to the error that occured.
Returns
received data
- (void) setMaxTimeoutForRead: (NSInteger)  paramMaxTimeoutForRead

Set the maximum time, in milliseconds, to wait for any data to be received.

Parameters
paramMaxTimeoutForReadthe maximum time, in milliseconds, to wait for any data to be received.
- (void) setTimeToWaitForMoreData: (NSInteger)  paramMimeToWaitForMoreData

Set the maximum time, in milliseconds, to wait in-between reads after the initial read.

Parameters
paramMimeToWaitForMoreDatathe maximum time, in milliseconds, to wait in-between reads after the initial read.
- (NSString *) toString

See the classes which implement this method for the format of the description string.

Returns
The connection description string.
- (void) waitForData: (NSInteger)  maxTimeout

Causes the currently executing thread to sleep until hasBytesAvailable equals YES, or for a maximum of maxTimeout milliseconds.

Parameters
maxTimeoutMaximum time in milliseconds to wait for an initial response from the printer.
- (NSInteger) write: (NSData *)  data
error: (NSError **)  error 

Writes the number of bytes from data to the connection.

The connection must be open before this method is called. If write:error: is called when a connection is closed, -1 is returned.

Parameters
dataThe data.
errorWill be set to the error that occured.
Returns
The number of bytes written or -1 if an error occurred.
- (NSInteger) write: (NSData *)  data
withOffset: (NSInteger)  offset
andWithLength: (NSInteger)  length
error: (NSError **)  error 

Writes length bytes from data starting at offset.

T. The connection must be open before this method is called. If write:error: is called when a connection is closed, -1 is returned.

Parameters
dataThe data.
errorWill be set to the error that occured.
Returns
The number of bytes written or -1 if an error occurred.
- (NSInteger) writeStream: (NSInputStream *)  dataSource
error: (NSError **)  error 

Writes all available bytes from the data source to the connection.

The connection must be open before this method is called. If write:error: is called when a connection is closed, -1 is returned.

Parameters
dataThe data.
errorWill be set to the error that occured.
Returns
The number of bytes written or -1 if an error occurred.

The documentation for this protocol was generated from the following file: