Stay organized with collections
Save and categorize content based on your preferences.
Firebase.Database.OnDisconnect
The OnDisconnect class is used to manage operations that will be Run on the server when this client disconnects.
Summary
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 DatabaseReference.onDisconnect()
on a FirebaseDatabase ref.
Public functions
|
Cancel()
|
Task
Cancel any disconnect operations that are queued up at this location
|
RemoveValue()
|
Task
Remove the value at this location when the client disconnects
|
SetValue(object value)
|
Task
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).
|
SetValue(object value, string priority)
|
Task
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).
|
SetValue(object value, double priority)
|
Task
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).
|
UpdateChildren(IDictionary< string, object > update)
|
Task
Ensure the data has the specified child values updated when the client is disconnected
|
Public functions
Cancel
Task Cancel()
Cancel any disconnect operations that are queued up at this location
Details |
Returns
|
The Task{TResult} for this operation.
|
RemoveValue
Task RemoveValue()
Remove the value at this location when the client disconnects
Details |
Returns
|
The Task{TResult} for this operation.
|
SetValue
Task 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).
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 |
value
|
The value to be set when a disconnect occurs
|
|
Returns
|
The Task{TResult} for this operation.
|
SetValue
Task 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).
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 |
value
|
The value to be set when a disconnect occurs
|
priority
|
The priority to be set when a disconnect occurs
|
|
Returns
|
The Task{TResult} for this operation.
|
SetValue
Task 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).
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 |
value
|
The value to be set when a disconnect occurs
|
priority
|
The priority to be set when a disconnect occurs
|
|
Returns
|
The Task{TResult} for this operation.
|
UpdateChildren
Task UpdateChildren(
IDictionary< string, object > update
)
Ensure the data has the specified child values updated when the client is disconnected
Details |
Parameters |
update
|
The paths to update, along with their desired values
|
|
Returns
|
The Task{TResult} for this operation.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-07-27 UTC.
[null,null,["Last updated 2022-07-27 UTC."],[],[],null,["# Firebase.Database.OnDisconnect Class Reference\n\nFirebase.Database.OnDisconnect\n==============================\n\nThe [OnDisconnect](/docs/reference/unity/class/firebase/database/on-disconnect#class_firebase_1_1_database_1_1_on_disconnect) class is used to manage operations that will be Run on the server when this client disconnects.\n\nSummary\n-------\n\nThe [OnDisconnect](/docs/reference/unity/class/firebase/database/on-disconnect#class_firebase_1_1_database_1_1_on_disconnect) 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. \n\n\nInstances of this class are obtained by calling onDisconnect DatabaseReference.onDisconnect()\n\non a [Firebase](/docs/reference/unity/namespace/firebase#namespace_firebase)[Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) ref.\n\n| ### Public functions ||\n|---------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Cancel](#class_firebase_1_1_database_1_1_on_disconnect_1a7cae8b7402a7c4bfdc028620418e99c2)`()` | `Task` Cancel any disconnect operations that are queued up at this location |\n| [RemoveValue](#class_firebase_1_1_database_1_1_on_disconnect_1af30f149086a831fe1f28236cc63b4d72)`()` | `Task` Remove the value at this location when the client disconnects |\n| [SetValue](#class_firebase_1_1_database_1_1_on_disconnect_1aca4606de04684e23afe3303ca7fe2fa9)`(object value)` | `Task` 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). |\n| [SetValue](#class_firebase_1_1_database_1_1_on_disconnect_1a91a216dd87df98475e9b52d54b83a679)`(object value, string priority)` | `Task` 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). |\n| [SetValue](#class_firebase_1_1_database_1_1_on_disconnect_1a50d18d78ad92dc95cf216a986a1ad2b2)`(object value, double priority)` | `Task` 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). |\n| [UpdateChildren](#class_firebase_1_1_database_1_1_on_disconnect_1a8fd69769048a7607480020f6a7e88ab9)`(IDictionary\u003c string, object \u003e update)` | `Task` Ensure the data has the specified child values updated when the client is disconnected |\n\nPublic functions\n----------------\n\n### Cancel\n\n```c#\nTask Cancel()\n``` \nCancel any disconnect operations that are queued up at this location\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|---------------------------------------|\n| **Returns** | The Task{TResult} for this operation. |\n\n### RemoveValue\n\n```c#\nTask RemoveValue()\n``` \nRemove the value at this location when the client disconnects\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|---------------------------------------|\n| **Returns** | The Task{TResult} for this operation. |\n\n### SetValue\n\n```c#\nTask SetValue(\n object value\n)\n``` \nEnsure 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).\n\nEnsure 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). \n\n\nThis 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.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------|\n| Parameters | |---------|----------------------------------------------| | `value` | The value to be set when a disconnect occurs | |\n| **Returns** | The Task{TResult} for this operation. |\n\n### SetValue\n\n```c#\nTask SetValue(\n object value,\n string priority\n)\n``` \nEnsure 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).\n\nEnsure 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). \n\n\nThis 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.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |------------|-------------------------------------------------| | `value` | The value to be set when a disconnect occurs | | `priority` | The priority to be set when a disconnect occurs | |\n| **Returns** | The Task{TResult} for this operation. |\n\n### SetValue\n\n```c#\nTask SetValue(\n object value,\n double priority\n)\n``` \nEnsure 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).\n\nEnsure 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). \n\n\nThis 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.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |------------|-------------------------------------------------| | `value` | The value to be set when a disconnect occurs | | `priority` | The priority to be set when a disconnect occurs | |\n| **Returns** | The Task{TResult} for this operation. |\n\n### UpdateChildren\n\n```c#\nTask UpdateChildren(\n IDictionary\u003c string, object \u003e update\n)\n``` \nEnsure the data has the specified child values updated when the client is disconnected\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |----------|------------------------------------------------------| | `update` | The paths to update, along with their desired values | |\n| **Returns** | The Task{TResult} for this operation. |"]]