Summary: Methods | Inherited Methods | [Expand All]
public class

# OnDisconnect

extends Object

java.lang.Object
↳ | com.google.firebase.database.OnDisconnect

## Class Overview

The OnDisconnect class is used to manage operations that will be run on the server when this client disconnects. It can be used to add or remove data based on a client's connection status. It is very useful in applications looking for 'presence' functionality.
Instances of this class are obtained by calling `onDisconnect` on a Firebase Database ref.

## Summary

Public Methods
Task<Void> | cancel() Cancel any disconnect operations that are queued up at this location
void | cancel(DatabaseReference.CompletionListener listener) Cancel any disconnect operations that are queued up at this location
Task<Void> | removeValue() Remove the value at this location when the client disconnects
void | removeValue(DatabaseReference.CompletionListener listener) Remove the value at this location when the client disconnects
void | setValue(Object value, double priority, DatabaseReference.CompletionListener listener) Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
void | setValue(Object value, Map priority, DatabaseReference.CompletionListener listener) Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
Task<Void> | setValue(Object value, String priority) Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
Task<Void> | setValue(Object value, double priority) Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
void | setValue(Object value, String priority, DatabaseReference.CompletionListener listener) Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
void | setValue(Object value, DatabaseReference.CompletionListener listener) Ensure the data at this location is set to the specified value when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
Task<Void> | setValue(Object value) Ensure the data at this location is set to the specified value when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
Task<Void> | updateChildren(Map<String, Object> update) Ensure the data has the specified child values updated when the client is disconnected
void | updateChildren(Map<String, Object> update, DatabaseReference.CompletionListener listener) Ensure the data has the specified child values updated when the client is disconnected

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Public Methods

#### public Task<Void> cancel ()

Cancel any disconnect operations that are queued up at this location

##### Returns

- The `Task` for this operation.

#### public void cancel (DatabaseReference.CompletionListener listener)

Cancel any disconnect operations that are queued up at this location

##### Parameters

listener | A listener that will be triggered once the server has cancelled the operations

#### public Task<Void> removeValue ()

Remove the value at this location when the client disconnects

##### Returns

- The `Task` for this operation.

#### public void removeValue (DatabaseReference.CompletionListener listener)

Remove the value at this location when the client disconnects

##### Parameters

listener | A listener that will be triggered once the server has queued up the operation

#### public void setValue (Object value, double priority, DatabaseReference.CompletionListener listener)

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

##### Parameters

value | The value to be set when a disconnect occurs
priority | The priority to be set when a disconnect occurs
listener | A listener that will be triggered once the server has queued up the operation

#### public void setValue (Object value, Map priority, DatabaseReference.CompletionListener listener)

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

##### Parameters

value | The value to be set when a disconnect occurs
priority | The priority to be set when a disconnect occurs
listener | A listener that will be triggered once the server has queued up the operation

#### public Task<Void> setValue (Object value, String priority)

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

##### Parameters

value | The value to be set when a disconnect occurs
priority | The priority to be set when a disconnect occurs

##### Returns

- The `Task` for this operation.

#### public Task<Void> setValue (Object value, double priority)

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

##### Parameters

value | The value to be set when a disconnect occurs
priority | The priority to be set when a disconnect occurs

##### Returns

- The `Task` for this operation.

#### public void setValue (Object value, String priority, DatabaseReference.CompletionListener listener)

Ensure the data at this location is set to the specified value and priority when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

##### Parameters

value | The value to be set when a disconnect occurs
priority | The priority to be set when a disconnect occurs
listener | A listener that will be triggered once the server has queued up the operation

#### public void setValue (Object value, DatabaseReference.CompletionListener listener)

Ensure the data at this location is set to the specified value when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

##### Parameters

value | The value to be set when a disconnect occurs
listener | A listener that will be triggered once the server has queued up the operation

#### public Task<Void> setValue (Object value)

Ensure the data at this location is set to the specified value when the client is disconnected (due to closing the browser, navigating to a new page, or network issues).
This method is especially useful for implementing "presence" systems, where a value should be changed or cleared when a user disconnects so that they appear "offline" to other users.

##### Parameters

value | The value to be set when a disconnect occurs

##### Returns

- The `Task` for this operation.

#### public Task<Void> updateChildren (Map<String, Object> update)

Ensure the data has the specified child values updated when the client is disconnected

##### Parameters

update | The paths to update, along with their desired values

##### Returns

- The `Task` for this operation.

#### public void updateChildren (Map<String, Object> update, DatabaseReference.CompletionListener listener)

Ensure the data has the specified child values updated when the client is disconnected

##### Parameters

update | The paths to update, along with their desired values
listener | A listener that will be triggered once the server has queued up the operation