def on_disconnect(obj=nil, &block)
      @on_disconnect_obj = obj
      @on_disconnect = Proc.new { |handle, obj_ptr|
        # On disconnect, we'll need to remove all of our change handlers
        @listeners.each_pair do |pattern, (listener, proc)|
          Klass.remove_OnKeyChange_Handler(listener.get_pointer(0))
          sleep @handler_sleep
        end
        yield self, object_for(obj_ptr)
      }
      Klass.set_OnServerDisconnect_Handler(@handle, @on_disconnect, pointer_for(obj))
      sleep @handler_sleep
    end
def on_disconnect(obj=nil, &block)
      @on_disconnect_obj = obj
      @on_disconnect = Proc.new { |handle, obj_ptr|
        # On disconnect, we'll need to remove all of our change handlers
        @listeners.each_pair do |pattern, (listener, proc)|
          Klass.remove_OnKeyChange_Handler(listener.get_pointer(0))
          sleep @handler_sleep
        end
        yield self, object_for(obj_ptr)
      }
      Klass.set_OnServerDisconnect_Handler(@handle, @on_disconnect, pointer_for(obj))
      sleep @handler_sleep
    end
Sets a server disconnect handler callback function. This is called when a connection to the server has been lost.

 @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_disconnect do |obj|
       puts 'Disconnected'
     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