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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 def write(self, data):
     if self.channel is None:
         raise _socket.error("socket not connected")
     return \
         BBBluetoothChannelDelegate.synchronouslyWriteData_toL2CAPChannel_(
             buffer(data), self.channel)
Ejemplo n.º 4
0
 def write(self, data):
     if self.channel is None:
         raise _socket.error("socket not connected")
     return \
         BBBluetoothChannelDelegate.synchronouslyWriteData_toRFCOMMChannel_(
             memoryview(data.encode()), self.channel)
Ejemplo n.º 5
0
# 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)