Firebase. Database. OnDisconnect
TheOnDisconnect class is used to manage operations that will be Run on the server when this client disconnects.
Summary
TheOnDisconnect 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
Public functions | |
|---|---|
Cancel() | TaskCancel any disconnect operations that are queued up at this location |
RemoveValue() | TaskRemove the value at this location when the client disconnects |
SetValue(object value) | TaskEnsure 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). |
SetValue(object value, string priority) | TaskEnsure 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). |
SetValue(object value, double priority) | TaskEnsure 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). |
UpdateChildren(IDictionary< string, object > update) | TaskEnsure the data has the specified child values updated when the client is disconnected |
Public functions
Cancel
TaskCancel()
Cancel any disconnect operations that are queued up at this location
| Details | |
|---|---|
| Returns | The Task{TResult} for this operation. |
RemoveValue
TaskRemoveValue()
Remove the value at this location when the client disconnects
| Details | |
|---|---|
| Returns | The Task{TResult} for this operation. |
SetValue
TaskSetValue(objectvalue)
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).
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.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | The Task{TResult} for this operation. |
SetValue
TaskSetValue(objectvalue,stringpriority)
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).
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.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | The Task{TResult} for this operation. |
SetValue
TaskSetValue(objectvalue,doublepriority)
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).
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.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | The Task{TResult} for this operation. |
UpdateChildren
TaskUpdateChildren(IDictionary<string,object>update)
Ensure the data has the specified child values updated when the client is disconnected
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | The Task{TResult} for this operation. |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-07-27 UTC.