-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
51 lines (44 loc) · 1.67 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Newtonsoft.Json.Linq;
using System;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Cache;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleAppTeste
{
class Program
{
static void Main(string[] args)
{
var task = Task.Run(async () => await ConectarWebSocket());
Task.WaitAll(task);
}
private static async Task ConectarWebSocket()
{
string url;
IWebSocketClient webSocketClient = new FoxbitWebSocketClient();
ClientWebSocket clientWebSocket = new ClientWebSocket();
JObject login = new JObject();
login["MsgType"] = ConstantesMensagem.MESSAGE_TYPE_TO_LOGIN;
login["UserReqID"] = new Random().Next(0, 1000);
login["BrokerID"] = 4;//foxbit
login["Username"] = ConfigurationManager.AppSettings["foxbitUserName"];
login["Password"] = ConfigurationManager.AppSettings["foxbitSecret"];
login["UserReqTyp"] = "1";
login["FingerPrint"] = "";
url = ConfigurationManager.AppSettings["foxbitUrl"];
await webSocketClient.Conectar(url);
await webSocketClient.Autenticar(login);
JObject historicoTrade = new JObject();
historicoTrade["MsgType"] = ConstantesMensagem.MESSAGE_TYPE_LEGDER;
historicoTrade["LedgerListReqID"] = new Random().Next(0, 1000);
await webSocketClient.EnviarMensagem(historicoTrade.ToString());
var retorno = await webSocketClient.ReceberMensagem();
}
}
}