def on_connect(obj=nil, &block)
      @on_connect_obj = obj
      @on_connect = Proc.new { |handle, obj_ptr|
        # On connect, we'll need to re-add all of our change handlers
        @listeners.each_pair do |pattern, (listener, proc)|
          begin
            next if status != :connected
            Klass.set_OnKeyChange_Handler(@handle, listener, pattern, proc, pointer_for(obj))              
            sleep @handler_sleep
          rescue
            Phidgets::Log.error("#{self.class}::on_connect", $!.to_s)
          end
        end
        yield self, object_for(obj_ptr)
      }
      Klass.set_OnServerConnect_Handler(@handle, @on_connect, pointer_for(obj))
      sleep @handler_sleep
    end
def on_connect(obj=nil, &block)
      @on_connect_obj = obj
      @on_connect = Proc.new { |handle, obj_ptr|
        # On connect, we'll need to re-add all of our change handlers
        @listeners.each_pair do |pattern, (listener, proc)|
          begin
            next if status != :connected
            Klass.set_OnKeyChange_Handler(@handle, listener, pattern, proc, pointer_for(obj))              
            sleep @handler_sleep
          rescue
            Phidgets::Log.error("#{self.class}::on_connect", $!.to_s)
          end
        end
        yield self, object_for(obj_ptr)
      }
      Klass.set_OnServerConnect_Handler(@handle, @on_connect, pointer_for(obj))
      sleep @handler_sleep
    end
Sets a server connect handler callback function. This is called when a connection to the server has been made.

 @param [String] obj Object to pass to the callback function. This is optional.
 @param [Proc] Block When the callback is executed, the device and object are yielded to this block.
 @example
     dict.on_connect do |obj|
       puts 'Connected'
     end
 As this runs in it's own thread, be sure that all errors are properly handled or the thread will halt and not fire any more.
 @return [Boolean] returns true or raises an error