Class

OBEXSession

Object representing an OBEX connection to a remote target.

Declaration

@interface OBEXSession : NSObject

Overview

You will have no need for a obtaining/using a raw OBEXSession, since it requires an underlying transport to do anything useful. However, once you have an object that is a subclass of this class, you can use the functions herein to manipulate that OBEXSession. First off, you will want to use OBEXConnect (if you are a client session) to actually cause the transport to open a connection to a remote target and establish an OBEX connection over it. From there you can issue more commands based on the responses from a server.

If you are a server session, the first thing you should receive is an OBEXConnect command packet, and you will want to issue an OBEXConnectResponse packet, with your reesponse to that command (success, denied, bad request, etc.).

You can use the session accessors to access certain information, such as the negotiated max packet length.

If you wish to implement your own OBEXSession over a transport such as ethernet, you will need to see the end of the file to determine which functions to override, and what to pass to those functions.

No timeout mechanism has been implemented so far for an OBEXSessions. If you need timeouts, you will need to implement them yourself. This is being explored for a future revision. However, be aware that the OBEX Specification does not explicitly require timeouts, so be sure you allow ample time for commands to complete, as some devices may be slow when sending large amounts of data.

Topics

Instance Methods

- OBEXAbort:optionalHeadersLength:eventSelector:selectorTarget:refCon:

Send an OBEX Abort command to the session's target.

- OBEXConnect:maxPacketLength:optionalHeaders:optionalHeadersLength:eventSelector:selectorTarget:refCon:

Initiate an OBEX connection to a device. Causes underlying transport (Bluetooth, et al) to attempt to connect to a remote device. After success, an OBEX connect packet is sent to establish the OBEX Connection.

- OBEXDisconnect:optionalHeadersLength:eventSelector:selectorTarget:refCon:

Send an OBEX Disconnect command to the session's target. THIS DOES NOT necessarily close the underlying transport connection. Deleting the session will ensure that closure.

- OBEXGet:headers:headersLength:eventSelector:selectorTarget:refCon:

Send an OBEX Get command to the session's target.

- clientHandleIncomingData:

Tranport subclasses need to invoke this from their own data-receive handlers. For example, when data is received over a Bluetooth RFCOMM channel in the IOBluetoothOBEXSession, it in turn calls this to dispatch the data. If you do not handle this case, your server session will not work, guaranteed.

- closeTransportConnection

You must override this - it will be called when the transport connection should be shutdown.

- getAvailableCommandPayloadLength:

Determine the maximum amount of data you can send in a particular command as an OBEX client session.

- getAvailableCommandResponsePayloadLength:

Determine the maximum amount of data you can send in a particular command response as an OBEX server session.

- getMaxPacketLength

Gets current max packet length.

- hasOpenOBEXConnection

Has a successful connect packet been sent and received? This API tells you so.

- hasOpenTransportConnection

You must override this - it will be called periodically to determine if a transport connection is open or not.

- openTransportConnection:selectorTarget:refCon:

Opens a transport connection to a device. A Bluetooth connection is one example of a transport.

- sendDataToTransport:dataLength:

You must override this to send data over your transport. This does nothing by default, it will return a kOBEXUnsupportedError.

- serverHandleIncomingData:

Tranport subclasses need to invoke this from their own data-receive handlers. For example, when data is received over a Bluetooth RFCOMM channel in the IOBluetoothOBEXSession, it in turn calls this to dispatch the data. If you do not handle this case, your server session will not work, guaranteed.

- setEventCallback:

Sets the C-API callback used when the session recieves data.

- setEventRefCon:

Sets the C-API callback refCon used when the session recieves data.

- setEventSelector:target:refCon:

Allow you to set a selector to be called when events occur on the OBEX session.

Relationships

Inherits From