Skip to content

Instantly share code, notes, and snippets.

@marce1994
Created November 16, 2017 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marce1994/4db05bbe3609a8f9634f2e2779a48404 to your computer and use it in GitHub Desktop.
Save marce1994/4db05bbe3609a8f9634f2e2779a48404 to your computer and use it in GitHub Desktop.
WebsocketTest
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);
}
}
}
using System;
namespace Collectors
{
class Program
{
static void Main(string[] args)
{
BitfinexCollector client = new BitfinexCollector();
}
}
}
@barchito
Copy link

barchito commented Nov 16, 2017

var client = new xxxx();
While(true){
Thread.Sleep(100)
}
Console.ReadKey()

@marce1994
Copy link
Author

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