Skip to content

Commit c0a6bec

Browse files
committed
Renamed DualParseLiveQueryEventArgs to ParseLiveQueryDualEventArgs
1 parent 98e295a commit c0a6bec

File tree

7 files changed

+61
-52
lines changed

7 files changed

+61
-52
lines changed

Parse/Abstractions/Platform/LiveQueries/IParseLiveQueryController.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ namespace Parse.Abstractions.Platform.LiveQueries;
1111
/// </summary>
1212
public interface IParseLiveQueryController
1313
{
14+
/// <summary>
15+
/// Gets or sets the timeout duration, in milliseconds, for operations performed by the LiveQuery controller.
16+
/// </summary>
17+
/// <remarks>
18+
/// This property determines the maximum time the system will wait for an operation to complete
19+
/// before timing out. It is particularly relevant to tasks such as establishing a connection
20+
/// to the LiveQuery server or awaiting responses for subscription or query update requests.
21+
/// Developers can use this property to configure timeouts based on the expected network
22+
/// and performance conditions of the application environment.
23+
/// </remarks>
24+
public int TimeOut { get; set; }
25+
1426
/// <summary>
1527
/// Event triggered when an error occurs during the operation of the ParseLiveQueryController.
1628
/// </summary>

Parse/Abstractions/Platform/LiveQueries/IParseLiveQuerySubscription.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ public interface IParseLiveQuerySubscription
2424
/// This event is triggered when an object that did not previously match the query (and was thus not part of the subscription)
2525
/// starts matching the query, typically due to an update.
2626
/// </summary>
27-
public event EventHandler<DualParseLiveQueryEventArgs> Enter;
27+
public event EventHandler<ParseLiveQueryDualEventArgs> Enter;
2828

2929
/// <summary>
3030
/// Represents the Update event for a live query subscription.
3131
/// This event is triggered when an existing object matching the subscription's query is updated.
3232
/// </summary>
33-
public event EventHandler<DualParseLiveQueryEventArgs> Update;
33+
public event EventHandler<ParseLiveQueryDualEventArgs> Update;
3434

3535
/// <summary>
3636
/// Represents the Leave event for a live query subscription.
3737
/// This event is triggered when an object that previously matched the subscription's query
3838
/// no longer matches the criteria and is removed.
3939
/// </summary>
40-
public event EventHandler<DualParseLiveQueryEventArgs> Leave;
40+
public event EventHandler<ParseLiveQueryDualEventArgs> Leave;
4141

4242
/// <summary>
4343
/// Represents the Delete event for a live query subscription.

Parse/Platform/LiveQueries/DualParseLiveQueryEventArgs.cs renamed to Parse/Platform/LiveQueries/ParseLiveQueryDualEventArgs.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,20 @@ namespace Parse.Platform.LiveQueries;
55
/// This class encapsulates details about a particular event, such as the operation type,
66
/// client ID, request ID, and the associated Parse object data.
77
/// </summary>
8-
public class DualParseLiveQueryEventArgs : ParseLiveQueryEventArgs
8+
public class ParseLiveQueryDualEventArgs : ParseLiveQueryEventArgs
99
{
10-
/// <summary>
11-
/// Represents the event arguments provided to Live Query event handlers in the Parse platform.
12-
/// This class provides information about the current and original state of the Parse object
13-
/// involved in the Live Query operation.
14-
/// </summary>
15-
internal DualParseLiveQueryEventArgs(ParseObject current, ParseObject original) : base(current)
16-
{
17-
Original = original;
18-
}
19-
2010
/// <summary>
2111
/// Gets the state of the Parse object before the live query event was triggered.
2212
/// This property represents the original data of the Parse object prior to any updates,
2313
/// providing a snapshot of its previous state for comparison purposes during events
2414
/// such as updates or deletes.
2515
/// </summary>
2616
public ParseObject Original { get; private set; }
17+
18+
/// <summary>
19+
/// Represents the event arguments provided to Live Query event handlers in the Parse platform.
20+
/// This class provides information about the current and original state of the Parse object
21+
/// involved in the Live Query operation.
22+
/// </summary>
23+
internal ParseLiveQueryDualEventArgs(ParseObject current, ParseObject original) : base(current) => Original = original;
2724
}

Parse/Platform/LiveQueries/ParseLiveQueryErrorEventArgs.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ namespace Parse.Platform.LiveQueries;
77
/// </summary>
88
public class ParseLiveQueryErrorEventArgs : EventArgs
99
{
10-
/// <summary>
11-
/// Represents the arguments for an error event that occurs during a live query in the Parse platform.
12-
/// </summary>
13-
internal ParseLiveQueryErrorEventArgs(int code, string error, bool reconnect)
14-
{
15-
Error = error;
16-
Code = code;
17-
Reconnect = reconnect;
18-
}
19-
2010
/// <summary>
2111
/// Gets or sets the error message associated with a live query operation.
2212
/// </summary>
@@ -48,4 +38,14 @@ internal ParseLiveQueryErrorEventArgs(int code, string error, bool reconnect)
4838
/// connection with the server.
4939
/// </remarks>
5040
public bool Reconnect { get; private set; }
41+
42+
/// <summary>
43+
/// Represents the arguments for an error event that occurs during a live query in the Parse platform.
44+
/// </summary>
45+
internal ParseLiveQueryErrorEventArgs(int code, string error, bool reconnect)
46+
{
47+
Error = error;
48+
Code = code;
49+
Reconnect = reconnect;
50+
}
5151
}

Parse/Platform/LiveQueries/ParseLiveQueryEventArgs.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,18 @@ namespace Parse.Platform.LiveQueries;
99
/// </summary>
1010
public class ParseLiveQueryEventArgs : EventArgs
1111
{
12-
/// <summary>
13-
/// Represents the event arguments provided to Live Query event handlers in the Parse platform.
14-
/// This class provides information about the current and original state of the Parse object
15-
/// involved in the Live Query operation.
16-
/// </summary>
17-
internal ParseLiveQueryEventArgs(ParseObject current)
18-
{
19-
Object = current;
20-
}
21-
2212
/// <summary>
2313
/// Gets the current state of the Parse object associated with the live query event.
2414
/// This property provides the details of the Parse object as it existed at the time
2515
/// the event was triggered, reflecting any changes made during operations such as
2616
/// an update or creation.
2717
/// </summary>
2818
public ParseObject Object { get; private set; }
19+
20+
/// <summary>
21+
/// Represents the event arguments provided to Live Query event handlers in the Parse platform.
22+
/// This class provides information about the current and original state of the Parse object
23+
/// involved in the Live Query operation.
24+
/// </summary>
25+
internal ParseLiveQueryEventArgs(ParseObject current) => Object = current;
2926
}

Parse/Platform/LiveQueries/ParseLiveQuerySubscription.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ public class ParseLiveQuerySubscription<T> : IParseLiveQuerySubscription where T
2929
/// This event is triggered when an object that did not previously match the query (and was thus not part of the subscription)
3030
/// starts matching the query, typically due to an update.
3131
/// </summary>
32-
public event EventHandler<DualParseLiveQueryEventArgs> Enter;
32+
public event EventHandler<ParseLiveQueryDualEventArgs> Enter;
3333

3434
/// <summary>
3535
/// Represents the Update event for a live query subscription.
3636
/// This event is triggered when an existing object matching the subscription's query is updated.
3737
/// </summary>
38-
public event EventHandler<DualParseLiveQueryEventArgs> Update;
38+
public event EventHandler<ParseLiveQueryDualEventArgs> Update;
3939

4040
/// <summary>
4141
/// Represents the Leave event for a live query subscription.
4242
/// This event is triggered when an object that previously matched the subscription's query
4343
/// no longer matches the criteria and is removed.
4444
/// </summary>
45-
public event EventHandler<DualParseLiveQueryEventArgs> Leave;
45+
public event EventHandler<ParseLiveQueryDualEventArgs> Leave;
4646

4747
/// <summary>
4848
/// Represents the Delete event for a live query subscription.
@@ -112,7 +112,7 @@ public void OnCreate(IObjectState objectState)
112112
/// <param name="originalState">The original state of the object before entering the query result set.</param>
113113
public void OnEnter(IObjectState objectState, IObjectState originalState)
114114
{
115-
Enter?.Invoke(this, new DualParseLiveQueryEventArgs(
115+
Enter?.Invoke(this, new ParseLiveQueryDualEventArgs(
116116
Services.GenerateObjectFromState<T>(objectState, ClassName),
117117
Services.GenerateObjectFromState<T>(originalState, ClassName)));
118118
}
@@ -125,7 +125,7 @@ public void OnEnter(IObjectState objectState, IObjectState originalState)
125125
/// <param name="originalState">The original state of the object before the update.</param>
126126
public void OnUpdate(IObjectState objectState, IObjectState originalState)
127127
{
128-
Update?.Invoke(this, new DualParseLiveQueryEventArgs(
128+
Update?.Invoke(this, new ParseLiveQueryDualEventArgs(
129129
Services.GenerateObjectFromState<T>(objectState, ClassName),
130130
Services.GenerateObjectFromState<T>(originalState, ClassName)));
131131
}
@@ -139,7 +139,7 @@ public void OnUpdate(IObjectState objectState, IObjectState originalState)
139139
/// <param name="originalState">The original state of the object before it left the result set.</param>
140140
public void OnLeave(IObjectState objectState, IObjectState originalState)
141141
{
142-
Leave?.Invoke(this, new DualParseLiveQueryEventArgs(
142+
Leave?.Invoke(this, new ParseLiveQueryDualEventArgs(
143143
Services.GenerateObjectFromState<T>(objectState, ClassName),
144144
Services.GenerateObjectFromState<T>(originalState, ClassName)));
145145
}

Parse/Utilities/ObjectServiceExtensions.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static T CreateObject<T>(this IServiceHub serviceHub) where T : ParseObje
9292
/// <returns>A new ParseObject for the given class name.</returns>
9393
public static T CreateObject<T>(this IParseObjectClassController classController, IServiceHub serviceHub) where T : ParseObject
9494
{
95-
95+
9696
return (T) classController.Instantiate(classController.GetClassName(typeof(T)), serviceHub);
9797
}
9898

@@ -289,18 +289,21 @@ public static ParseQuery<ParseObject> GetQuery(this IServiceHub serviceHub, stri
289289
}
290290

291291
/// <summary>
292-
/// Establishes a connection to the Live Query server using the provided <see cref="IServiceHub"/> instance.
293-
/// This method ensures that the Live Query controller initiates and maintains a persistent connection.
292+
/// Connects the Live Query server to the provided <see cref="IServiceHub"/> instance, enabling real-time updates for subscribed queries.
293+
/// Allows error handling during the connection and sets a custom timeout period for the connection.
294294
/// </summary>
295-
/// <param name="serviceHub">The service hub instance containing the Live Query controller to manage the connection.</param>
296-
/// <returns>A task that represents the asynchronous operation of connecting to the Live Query server.</returns>
297-
public static async Task ConnectLiveQueryServerAsync(this IServiceHub serviceHub, EventHandler<ParseLiveQueryErrorEventArgs> onError = null)
295+
/// <param name="serviceHub">The <see cref="IServiceHub"/> instance through which the Live Query server will be connected.</param>
296+
/// <param name="onError">An optional event handler to capture Live Query connection errors.</param>
297+
/// <param name="timeOut">An optional timeout value, in milliseconds, for the Live Query connection. Defaults to 5000 milliseconds.</param>
298+
/// <returns>A task representing the asynchronous operation of connecting to the Live Query server.</returns>
299+
public static async Task ConnectLiveQueryServerAsync(this IServiceHub serviceHub, EventHandler<ParseLiveQueryErrorEventArgs> onError = null, int timeOut = 5000)
298300
{
299301
await serviceHub.LiveQueryController.ConnectAsync();
300302
if (onError is not null)
301303
{
302304
serviceHub.LiveQueryController.Error += onError;
303305
}
306+
serviceHub.LiveQueryController.TimeOut = timeOut;
304307
}
305308

306309
/// <summary>
@@ -363,21 +366,21 @@ internal static T GenerateObjectFromState<T>(
363366
{
364367
throw new ArgumentNullException(nameof(state), "The state cannot be null.");
365368
}
366-
369+
367370
// Ensure the class name is determined or throw an exception
368371
string className = state.ClassName ?? defaultClassName;
369372
if (string.IsNullOrEmpty(className))
370373
{
371-
374+
372375
throw new InvalidOperationException("Both state.ClassName and defaultClassName are null or empty. Unable to determine class name.");
373376
}
374-
377+
375378
// Create the object using the class controller
376379
T obj = classController.Instantiate(className, serviceHub) as T;
377-
380+
378381
if (obj == null)
379382
{
380-
383+
381384
throw new InvalidOperationException($"Failed to instantiate object of type {typeof(T).Name} for class {className}.");
382385
}
383386

@@ -464,7 +467,7 @@ static void CollectDirtyChildren(this IServiceHub serviceHub, object node, IList
464467
{
465468
CollectDirtyChildren(serviceHub, node, dirtyChildren, new HashSet<ParseObject>(new IdentityEqualityComparer<ParseObject>()), new HashSet<ParseObject>(new IdentityEqualityComparer<ParseObject>()));
466469
}
467-
470+
468471
internal static async Task DeepSaveAsync(this IServiceHub serviceHub, object target, string sessionToken, CancellationToken cancellationToken)
469472
{
470473
// Collect dirty objects

0 commit comments

Comments
 (0)