Class

OBEXSession

Object representing an OBEX connection to a remote target.

Declaration

class 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

func obexConnect(OBEXFlags, maxPacketLength: OBEXMaxPacketLength, optionalHeaders: UnsafeMutableRawPointer!, optionalHeadersLength: Int, eventSelector: Selector!, selectorTarget: Any!, refCon: UnsafeMutableRawPointer!) -> OBEXError

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.

func obexDisconnect(UnsafeMutableRawPointer!, optionalHeadersLength: Int, eventSelector: Selector!, selectorTarget: Any!, refCon: UnsafeMutableRawPointer!) -> OBEXError

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.

func clientHandleIncomingData(UnsafeMutablePointer<OBEXTransportEvent>!)

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.

func closeTransportConnection() -> OBEXError

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

func getAvailableCommandPayloadLength(OBEXOpCode) -> OBEXMaxPacketLength

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

func getAvailableCommandResponsePayloadLength(OBEXOpCode) -> OBEXMaxPacketLength

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

func hasOpenOBEXConnection() -> Bool

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

func hasOpenTransportConnection() -> Bool

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

func openTransportConnection(Selector!, selectorTarget: Any!, refCon: UnsafeMutableRawPointer!) -> OBEXError

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

func sendData(toTransport: UnsafeMutableRawPointer!, dataLength: Int) -> OBEXError

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

func serverHandleIncomingData(UnsafeMutablePointer<OBEXTransportEvent>!)

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.

func setEventCallback(OBEXSessionEventCallback!)

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

func setEventRefCon(UnsafeMutableRawPointer!)

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

func setEventSelector(Selector!, target: Any!, refCon: Any!)

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

Relationships

Inherits From

Conforms To