Created
November 16, 2017 01:10
-
-
Save marce1994/4db05bbe3609a8f9634f2e2779a48404 to your computer and use it in GitHub Desktop.
WebsocketTest
This file contains hidden or 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
using SuperSocket.ClientEngine; | |
using System; | |
using WebSocket4Net; | |
namespace Collectors | |
{ | |
public class BitfinexCollector | |
{ | |
WebSocket websocket = new WebSocket("wss://api.bitfinex.com/ws"); | |
public BitfinexCollector() { | |
websocket.Opened += new EventHandler(websocket_OpenedAsync); | |
websocket.Error += new EventHandler<ErrorEventArgs>(websocket_Error); | |
websocket.Closed += new EventHandler(websocket_Closed); | |
websocket.MessageReceived += new EventHandler<MessageReceivedEventArgs>(websocket_MessageReceived); | |
websocket.Open(); | |
} | |
private void websocket_OpenedAsync(object sender, EventArgs e) | |
{ | |
Console.WriteLine("Socket Connected!"); | |
} | |
private void websocket_Error(object sender, EventArgs e) | |
{ | |
Console.WriteLine("Un error feo"); | |
} | |
private void websocket_Closed(object sender, EventArgs e) | |
{ | |
try | |
{ | |
Console.WriteLine("Reconecting..."); | |
websocket.Open(); | |
} | |
catch (Exception exception) | |
{ | |
Console.WriteLine("Ocurrio un error: " + exception.Message); | |
throw; | |
} | |
} | |
private void websocket_MessageReceived(object sender, MessageReceivedEventArgs e) | |
{ | |
Console.WriteLine(e.Message); | |
} | |
} | |
} |
This file contains hidden or 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
using System; | |
namespace Collectors | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
BitfinexCollector client = new BitfinexCollector(); | |
} | |
} | |
} |
No me funciona, no se que onda. no me suscribe al evento igual
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var client = new xxxx();
While(true){
Thread.Sleep(100)
}
Console.ReadKey()