-
-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,12 +383,28 @@ params string[] marketSymbols | |
|
||
var initialSequenceIds = new Dictionary<string, long>(); | ||
|
||
foreach (var marketSymbol in marketSymbols) | ||
{ | ||
var initialBook = await OnGetOrderBookAsync(marketSymbol, maxCount); | ||
initialBook.IsFromSnapshot = true; | ||
|
||
callback(initialBook); | ||
|
||
initialSequenceIds[marketSymbol] = initialBook.SequenceId; | ||
} | ||
|
||
return await ConnectPublicWebSocketAsync( | ||
string.Empty, | ||
(_socket, msg) => | ||
{ | ||
var json = msg.ToStringFromUTF8(); | ||
|
||
if (json.Contains("invalid") || json.Contains("Not Subscribed")) | ||
{ | ||
Logger.Warn(json); | ||
return Task.CompletedTask; | ||
} | ||
|
||
MarketDepthDiffUpdate update = null; | ||
try | ||
{ | ||
|
@@ -450,26 +466,15 @@ params string[] marketSymbols | |
}, | ||
async (_socket) => | ||
{ | ||
foreach (var marketSymbol in marketSymbols) // "Every websocket connection maximum support 30 subscriptions at one time." - API docs | ||
{ | ||
var initialBook = await OnGetOrderBookAsync(marketSymbol, maxCount); | ||
initialBook.IsFromSnapshot = true; | ||
|
||
callback(initialBook); | ||
|
||
initialSequenceIds[marketSymbol] = initialBook.SequenceId; | ||
|
||
var subscriptionParams = new List<string> | ||
{ | ||
$"[email protected]@{marketSymbol}" | ||
}; | ||
var subscriptionParams = marketSymbols | ||
.Select(ms => $"[email protected]@{ms}") | ||
.ToList(); | ||
|
||
await _socket.SendMessageAsync(new WebSocketSubscription | ||
{ | ||
Method = "SUBSCRIPTION", | ||
Params = subscriptionParams, | ||
}); | ||
} | ||
await _socket.SendMessageAsync(new WebSocketSubscription | ||
{ | ||
Method = "SUBSCRIPTION", | ||
Params = subscriptionParams, | ||
}); | ||
} | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters