public ZWebsocket(WebsocketApiCredentials credentials, string url) { this.credentials = credentials; this.socket = new PureSocketClusterSocket(url); this.socket.OnOpened += On_Opened; this.socket.OnMessage += On_Message; this.socket.OnClosed += On_Closed; this.socket.OnData += On_Data; this.socket.OnError += On_Error; this.socket.OnFatality += On_Fatality; this.socket.OnSendFailed += On_SendFailed; this.socket.OnStateChanged += On_StateChanged; // this.socket.OnSubscribe() }
private static int m_exch = 1; // 1=COINIGY, 2=BITFINEX, 3=GDAX public void Subscribe_And_Listen() { // Initialize an instance of our socket /*socket = new BitfinexWebsocket(new ApiCredentials * { * ApiKey = "402bf810f4d10e99b9bdea8b8f76304e", * ApiSecret = "b18bbbfbd2e8e0828b541603b5bf4613" * });*/ //socket = new BitfinexWebsocket(new WebsocketApiCredentials("lp1W7lgC8CesrgBUCLdL5XBgXHXh7hdv0Txu9TIjeDg", "cbZfggsZNLXoZaqY3sBRvj9ZXuOYb960mrVH7zibVUy")); // BITFINEX 1 //this.socket = new PureSocketClusterSocket("wss://api2.bitfinex.com:3000/ws"); //this.socket = new PureSocketClusterSocket("wss://api.bitfinex.com/ws/2"); //this.socket = new PureSocketClusterSocket("wss://api.bitfinex.com/ws"); WebsocketApiCredentials creds; if (m_exch == 1) { creds = new WebsocketApiCredentials("402bf810f4d10e99b9bdea8b8f76304e", "b18bbbfbd2e8e0828b541603b5bf4613"); zsocket = new ZWebsocket(creds, "wss://sc-02.coinigy.com/socketcluster/"); // COINIGY } else if (m_exch == 2) { creds = new WebsocketApiCredentials("4vRpraeVZQnet7ooxpAkul2fsInJFsxfasqDN9bHhLx", "MAyDsRlv3eQLZ7aqAYUTzExNGSSzOEFVdqrU2RWBVMW"); zsocket = new ZWebsocket(creds, "wss://api.bitfinex.com/ws"); // BITFINEX 2 } else if (m_exch == 3) { creds = new WebsocketApiCredentials("856ce8d659cf8f32a365037e62d06219", "29KJJ5aS2MYWbplvNr2OC1y9qpudruV4PWiC6BNdEuEnSrYWQNBJnoSFXaLmpJND7ysrxF7PM6p6fJDdxZRCDw=="); zsocket = new ZWebsocket(creds, "wss://ws-feed.gdax.com"); // GDAX } // Subscribe to OnClientReady-event so we know when we can subscribe to trade channels zsocket.OnClientReady += Socket_OnClientReady; // Subscribe to the OnTradeMessage-event so we can receive trade messages zsocket.OnTradeMessage += Socket_OnTradeMessage; // Finally we can connect to our socket and wait for incoming messages zsocket.Connect(); // Forces the methods not to exit resetEvent.WaitOne(); }
public ZWebsocket(WebsocketApiCredentials credentials, string url) { this.credentials = credentials; // Default url to socketcluster end-point is always "ws://somedomainname.com/socketcluster/" socket = new PureSocketClusterSocket(url); /*socket = new Socket(url); * socket.SetListerner(this); * //This will set automatic-reconnection to server with delay of 3 seconds and repeating it for 30 times * socket.SetReconnectStrategy(new ReconnectStrategy().SetMaxAttempts(30)); * //socket.SetReconnectStrategy(null); // to disable reconnection * socket.Connect();*/ this.socket.OnOpened += On_Opened; this.socket.OnMessage += On_Message; this.socket.OnClosed += On_Closed; this.socket.OnData += On_Data; this.socket.OnError += On_Error; this.socket.OnFatality += On_Fatality; this.socket.OnSendFailed += On_SendFailed; this.socket.OnStateChanged += On_StateChanged; // this.socket.OnSubscribe() }
public MyListener(WebsocketApiCredentials credentials) { this.credentials = credentials; }