Skip to content

Commit aec1d5b

Browse files
committed
Merge remote-tracking branch 'origin/master' into 2-dev
2 parents 84844df + a2b4902 commit aec1d5b

File tree

73 files changed

+1044
-250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1044
-250
lines changed

.ci/doc/templates/default.tpl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using KuzzleSdk.Exceptions;
1313
using KuzzleSdk.API.Options;
1414
using KuzzleSdk.API.DataObjects;
15+
using KuzzleSdk.API;
1516

1617
WebSocket socket = new WebSocket(new Uri("ws://kuzzle:7512"));
1718
KuzzleSdk.Kuzzle kuzzle = new KuzzleSdk.Kuzzle(socket);

.ci/doc/templates/empty.tpl.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#r "Kuzzle.dll"
2+
using System;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
6+
[snippet-code]
7+
8+
Console.WriteLine("Success");
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#r "Kuzzle.dll"
2+
using System;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using KuzzleSdk;
6+
using KuzzleSdk.Protocol;
7+
using Newtonsoft.Json.Linq;
8+
9+
WebSocket socket = new WebSocket(new Uri("ws://kuzzle:7512"));
10+
KuzzleSdk.Kuzzle kuzzle = new KuzzleSdk.Kuzzle(socket);
11+
12+
kuzzle.ConnectAsync(CancellationToken.None).Wait();
13+
14+
[snippet-code]
15+
16+
Console.WriteLine("Success");

Kuzzle/API/DataObjects/SearchResults.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace KuzzleSdk.API.DataObjects {
88
/// </summary>
99
public class SearchResults {
1010
/// <summary>
11-
/// Kuzzle instance
11+
/// Kuzzle instance
1212
/// </summary>
1313
protected readonly IKuzzleApi api;
1414

@@ -23,7 +23,7 @@ public class SearchResults {
2323
protected readonly JObject request;
2424

2525
/// <summary>
26-
/// To be overloaded by specialized SearchResult children
26+
/// To be overloaded by specialized SearchResults children
2727
/// </summary>
2828
protected readonly string scrollAction = "scroll";
2929

@@ -86,14 +86,16 @@ private JObject GetSearchAfterRequest() {
8686

8787
if (value.Type == JTokenType.String) {
8888
key = (string)value;
89-
} else {
89+
}
90+
else {
9091
key = (string)((JObject)value).First;
9192
}
9293

9394
if (key == "_uid") {
9495
searchAfter.Add((string)request["collection"] + "#"
9596
+ (string)lastItem["_id"]);
96-
} else {
97+
}
98+
else {
9799
searchAfter.Add(lastItem["_source"].SelectToken(key));
98100
}
99101
}
@@ -102,7 +104,7 @@ private JObject GetSearchAfterRequest() {
102104
}
103105

104106
/// <summary>
105-
/// Returns a new SearchResult object which contain the subsequent results
107+
/// Returns a new SearchResults object which contain the subsequent results
106108
/// of the search.
107109
/// </summary>
108110
public async Task<SearchResults> NextAsync() {
@@ -112,13 +114,15 @@ public async Task<SearchResults> NextAsync() {
112114

113115
if (ScrollId != null) {
114116
nextRequest = GetScrollRequest();
115-
} else if (
117+
}
118+
else if (
116119
options.Size != null &&
117120
request["body"]["sort"] != null &&
118121
request["body"]["sort"].Type != JTokenType.Null
119122
) {
120123
nextRequest = GetSearchAfterRequest();
121-
} else if (options.Size != null) {
124+
}
125+
else if (options.Size != null) {
122126
if (options.From != null && options.From > Total) {
123127
return null;
124128
}

Kuzzle/API/Options/SearchOptions.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ public class SearchOptions {
3737
]
3838
public string Scroll { get; set; }
3939

40+
/// <summary>
41+
/// Field to sort the result on
42+
/// </summary>
43+
[
44+
JsonProperty(
45+
PropertyName = "sort",
46+
NullValueHandling = NullValueHandling.Ignore
47+
)
48+
]
49+
public string Sort { get; set; }
50+
4051
/// <summary>
4152
/// Copy constructor.
4253
/// </summary>
@@ -45,14 +56,18 @@ public SearchOptions(SearchOptions src) {
4556
From = src.From;
4657
Size = src.Size;
4758

59+
if (src.Sort != null) {
60+
Sort = string.Copy(src.Sort);
61+
}
62+
4863
if (src.Scroll != null) {
4964
Scroll = string.Copy(src.Scroll);
5065
}
5166
}
5267
}
5368

5469
/// <summary>
55-
/// Initializes a new instance of the
70+
/// Initializes a new instance of the
5671
/// <see cref="T:KuzzleSdk.API.Options.SearchOptions"/> class.
5772
/// </summary>
5873
public SearchOptions() { }
Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
using System;
2-
using System.ComponentModel;
3-
using KuzzleSdk.API;
4-
using KuzzleSdk.EventHandler.Events;
5-
6-
namespace KuzzleSdk.EventHandler {
2+
using System.ComponentModel;
3+
using KuzzleSdk.API;
4+
using KuzzleSdk.EventHandler.Events;
5+
6+
namespace KuzzleSdk.EventHandler {
77
public sealed class KuzzleEventHandler : AbstractKuzzleEventHandler {
88

99
private IKuzzleApi kuzzle;
10-
10+
1111
public KuzzleEventHandler(IKuzzleApi kuzzle) {
12-
this.kuzzle = kuzzle;
13-
}
14-
15-
private EventHandlerList eventHandlerList = new EventHandlerList();
16-
17-
private static readonly object subscriptionEventKey = new object(); // Internal
12+
this.kuzzle = kuzzle;
13+
}
14+
15+
private EventHandlerList eventHandlerList = new EventHandlerList();
16+
17+
private static readonly object subscriptionEventKey = new object(); // Internal
1818
private static readonly object userLoggedInEventKey = new object(); // Internal
19-
private static readonly object userLoggedOutEventKey = new object(); // Internal
20-
private static readonly object reconnectedEventKey = new object(); // Public
21-
private static readonly object queueRecoveredEventKey = new object(); // Public
19+
private static readonly object userLoggedOutEventKey = new object(); // Internal
20+
private static readonly object reconnectedEventKey = new object(); // Public
21+
private static readonly object queueRecoveredEventKey = new object(); // Public
2222
private static readonly object unhandledResponseEventKey = new object(); // Public
23-
private static readonly object tokenExpiredEventKey = new object(); // Public
24-
23+
private static readonly object tokenExpiredEventKey = new object(); // Public
24+
2525
/// <summary>
2626
/// Occurs when we have to [add, remove, clear] subscriptions :
27-
/// </summary>
28-
public override event EventHandler<SubscriptionEvent> Subscription {
29-
add {
30-
eventHandlerList.AddHandler(subscriptionEventKey, value);
27+
/// </summary>
28+
public override event EventHandler<SubscriptionEvent> Subscription {
29+
add {
30+
eventHandlerList.AddHandler(subscriptionEventKey, value);
3131
}
3232

3333
remove {
3434
eventHandlerList.RemoveHandler(subscriptionEventKey, value);
35-
}
36-
}
37-
35+
}
36+
}
37+
3838
internal override void DispatchSubscription(SubscriptionEvent subscriptionData) {
3939
EventHandler<SubscriptionEvent> subscriptionEvent =
4040
(EventHandler<SubscriptionEvent>)eventHandlerList[subscriptionEventKey];
@@ -53,18 +53,18 @@ public override event EventHandler<UserLoggedInEvent> UserLoggedIn {
5353
remove {
5454
eventHandlerList.RemoveHandler(userLoggedInEventKey, value);
5555
}
56-
}
57-
56+
}
57+
5858
internal override void DispatchUserLoggedIn(string kuid) {
5959
EventHandler<UserLoggedInEvent> userLoggedIn =
6060
(EventHandler<UserLoggedInEvent>)eventHandlerList[userLoggedInEventKey];
6161

6262
userLoggedIn?.Invoke(this, new UserLoggedInEvent(kuid));
63-
}
63+
}
6464

6565
/// <summary>
6666
/// Occurs when the successfuly reconnected to the network
67-
/// </summary>
67+
/// </summary>
6868
public override event Action Reconnected {
6969
add {
7070
eventHandlerList.AddHandler(reconnectedEventKey, value);
@@ -73,16 +73,16 @@ public override event Action Reconnected {
7373
remove {
7474
eventHandlerList.RemoveHandler(reconnectedEventKey, value);
7575
}
76-
}
77-
76+
}
77+
7878
internal override void DispatchReconnected() {
7979
Action queueRecovered = (Action)eventHandlerList[reconnectedEventKey];
8080
queueRecovered?.Invoke();
81-
}
81+
}
8282

8383
/// <summary>
8484
/// Occurs when the offline queue of query has been successfuly recovered
85-
/// </summary>
85+
/// </summary>
8686
public override event Action QueueRecovered {
8787
add {
8888
eventHandlerList.AddHandler(queueRecoveredEventKey, value);
@@ -91,8 +91,8 @@ public override event Action QueueRecovered {
9191
remove {
9292
eventHandlerList.RemoveHandler(queueRecoveredEventKey, value);
9393
}
94-
}
95-
94+
}
95+
9696
internal override void DispatchQueueRecovered() {
9797
Action queueRecovered = (Action)eventHandlerList[queueRecoveredEventKey];
9898
queueRecovered?.Invoke();
@@ -101,42 +101,45 @@ internal override void DispatchQueueRecovered() {
101101
/// <summary>
102102
/// Occurs when an unhandled response is received.
103103
/// </summary>
104-
public override event EventHandler<Response> UnhandledResponse {
104+
public override event EventHandler<Response> UnhandledResponse {
105105
add {
106106
eventHandlerList.AddHandler(unhandledResponseEventKey, value);
107107
}
108108

109109
remove {
110110
eventHandlerList.RemoveHandler(unhandledResponseEventKey, value);
111-
}
111+
}
112112
}
113113

114114
internal override void DispatchUnhandledResponse(Response response) {
115115
EventHandler<Response> unhandledResponse =
116116
(EventHandler<Response>)eventHandlerList[unhandledResponseEventKey];
117117

118-
unhandledResponse?.Invoke(this, response);
119-
}
120-
118+
unhandledResponse?.Invoke(this, response);
119+
}
120+
121121
/// <summary>
122-
/// Token expiration event
122+
/// Token expiration event
123123
/// </summary>
124-
public override event Action TokenExpired {
124+
public override event Action TokenExpired {
125125
add {
126126
eventHandlerList.AddHandler(tokenExpiredEventKey, value);
127127
}
128128

129129
remove {
130130
eventHandlerList.RemoveHandler(tokenExpiredEventKey, value);
131-
}
132-
}
133-
131+
}
132+
}
133+
134134
internal override void DispatchTokenExpired() {
135135
kuzzle.AuthenticationToken = null;
136136
Action tokenExpired = (Action)eventHandlerList[tokenExpiredEventKey];
137137
tokenExpired?.Invoke();
138-
}
138+
}
139139

140+
/// <summary>
141+
/// Occurs when a user has logged out.
142+
/// </summary>
140143
public override event Action UserLoggedOut {
141144
add {
142145
eventHandlerList.AddHandler(userLoggedOutEventKey, value);
@@ -146,10 +149,10 @@ public override event Action UserLoggedOut {
146149
eventHandlerList.RemoveHandler(userLoggedOutEventKey, value);
147150
}
148151
}
149-
150-
internal override void DispatchUserLoggedOut() {
152+
153+
internal override void DispatchUserLoggedOut() {
151154
Action userLoggedOut = (Action)eventHandlerList[userLoggedOutEventKey];
152-
userLoggedOut?.Invoke();
153-
}
154-
}
155-
}
155+
userLoggedOut?.Invoke();
156+
}
157+
}
158+
}

Kuzzle/Kuzzle.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,6 @@ public bool AutoRecover {
195195
/// </summary>
196196
public string AuthenticationToken { get; set; }
197197

198-
/// <summary>
199-
/// Authentication token (deprecated, use AuthenticationToken instead)
200-
/// </summary>
201-
[Obsolete(
202-
"The Jwt property is deprecated, use AuthencationToken instead", false)]
203-
string Jwt {
204-
get { return AuthenticationToken; }
205-
set { AuthenticationToken = value; }
206-
}
207-
208198
/// <summary>
209199
/// Network Protocol
210200
/// </summary>
@@ -279,7 +269,8 @@ public Kuzzle(
279269
int minTokenDuration = 3600000,
280270
int maxQueueSize = -1,
281271
int maxRequestDelay = 1000,
282-
Func<JObject, bool> queueFiler = null
272+
bool autoRecover = false,
273+
Func<JObject, bool> queueFilter = null
283274
) {
284275
NetworkProtocol = networkProtocol;
285276
NetworkProtocol.ResponseEvent += ResponsesListener;
@@ -302,7 +293,8 @@ public Kuzzle(
302293
MinTokenDuration = minTokenDuration,
303294
MaxQueueSize = maxQueueSize,
304295
MaxRequestDelay = maxRequestDelay,
305-
QueueFilter = queueFiler
296+
QueueFilter = queueFilter,
297+
AutoRecover = autoRecover
306298
};
307299

308300
// Initializes instance unique properties

doc/2/controllers/auth/check-token/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
code: true
33
type: page
44
title: CheckTokenAsync
5-
description: Checks a JWT Token's validity.
5+
description: Checks an authentication Token's validity.
66
---
77

88
# CheckTokenAsync
99

10-
Checks a JWT Token's validity.
10+
Checks an authentication token's validity.
1111

1212
## Arguments
1313

@@ -17,7 +17,7 @@ public async Task<JObject> CheckTokenAsync(string token);
1717

1818
| Argument | Type | Description |
1919
|----------|-------------------|-------------|
20-
| `token` | <pre>string</pre> | JWT token |
20+
| `token` | <pre>string</pre> | Authentication token |
2121

2222
## Return
2323

0 commit comments

Comments
 (0)