def initWithDelegate_(self, cb_obj): """ Arguments: - cb_obj: An object that receives callbacks when events occur. This object should have: - a method '_handle_channeldata' which takes the related channel (a IOBluetoothRFCOMMChannel or IOBluetoothL2CAPChannel) and the new data (a string) as the arguments. - a method '_handle_channelclosed' which takes the related channel as the argument. If this listener's delegate is passed to the openRFCOMMChannel... or openL2CAPChannel... selectors as the delegate, the delegate (and therefore this listener) will automatically start receiving events. Otherwise, call setDelegate_() on the channel with this listener's delegate as the argument to allow this listener to start receiving channel events. (This is the only option for server-spawned sockets.) """ self = super(_ChannelEventListener, self).init() if cb_obj is None: raise TypeError("callback object is None") self.__cb_obj = cb_obj self.__closenotif = None self.__channelDelegate = \ BBBluetoothChannelDelegate.alloc().initWithDelegate_(self) return self
def initWithDelegate_(self, cb_obj): """ Arguments: - cb_obj: An object that receives callbacks when events occur. This object should have: - a method '_handle_channeldata' which takes the related channel (a IOBluetoothRFCOMMChannel or IOBluetoothL2CAPChannel) and the new data (a string) as the arguments. - a method '_handle_channelclosed' which takes the related channel as the argument. If this listener's delegate is passed to the openRFCOMMChannel... or openL2CAPChannel... selectors as the delegate, the delegate (and therefore this listener) will automatically start receiving events. Otherwise, call setDelegate_() on the channel with this listener's delegate as the argument to allow this listener to start receiving channel events. (This is the only option for server-spawned sockets.) """ self = super(_ChannelEventListener, self).init() if cb_obj is None: raise TypeError("callback object is None") self.__cb_obj = cb_obj self.__closenotif = None self.__channelDelegate = \ BBBluetoothChannelDelegate.alloc().initWithDelegate_(self) return self
def write(self, data): if self.channel is None: raise _socket.error("socket not connected") return \ BBBluetoothChannelDelegate.synchronouslyWriteData_toL2CAPChannel_( buffer(data), self.channel)
def write(self, data): if self.channel is None: raise _socket.error("socket not connected") return \ BBBluetoothChannelDelegate.synchronouslyWriteData_toRFCOMMChannel_( memoryview(data.encode()), self.channel)
# Copyright (c) 2009 Bea Lam. All rights reserved.
# Copyright (c) 2009 Bea Lam. All rights reserved.
def write(self, data): if self.channel is None: raise _socket.error("socket not connected") return \ BBBluetoothChannelDelegate.synchronouslyWriteData_toL2CAPChannel_( buffer(data), self.channel)