}
CoinfloorUtils.checkSuccess(jsonData);
if (jsonData.containsKey("tag")) {
switch (((Integer) jsonData.get("tag") & (1 << 10) - 1)) {
case 1:
CoinfloorExchangeEvent authenticationEvent = new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.AUTHENTICATION, event.getData(), jsonData);
addToEventQueue(authenticationEvent);
break;
case 101:
CoinfloorExchangeEvent getBalancesEvent =
new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_WALLET, event.getData(), coinfloorAdapters.adaptBalances(event.getData()));
addToEventQueue(getBalancesEvent);
break;
case 102:
case 103:
CoinfloorExchangeEvent getTradeVolumeEvent =
new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_TRADE_VOLUME, event.getData(), coinfloorAdapters.adaptTradeVolume(event.getData()));
addToEventQueue(getTradeVolumeEvent);
break;
case 201:
CoinfloorExchangeEvent watchOrdersReturn =
new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.SUBSCRIBE_ORDERS, event.getData(), coinfloorAdapters.adaptOrders(event.getData()));
addToEventQueue(watchOrdersReturn);
break;
case 202:
CoinfloorExchangeEvent watchTickerReturn =
new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.SUBSCRIBE_TICKER, event.getData(), coinfloorAdapters.adaptTicker(event.getData()));
addToEventQueue(watchTickerReturn);
break;
case 301:
CoinfloorExchangeEvent getOpenOrdersReturn =
new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_ORDERS_LIST, event.getData(), coinfloorAdapters.adaptOpenOrders(event.getData()));
addToEventQueue(getOpenOrdersReturn);
break;
case 302:
CoinfloorExchangeEvent placeOrderReturn =
new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_ORDER, event.getData(), coinfloorAdapters.adaptPlaceOrder(event.getData()));
addToEventQueue(placeOrderReturn);
break;
case 303:
CoinfloorExchangeEvent cancelOrderReturn =
new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_ORDER_CANCELED, event.getData(), coinfloorAdapters.adaptCancelOrder(event.getData()));
addToEventQueue(cancelOrderReturn);
break;
case 304:
CoinfloorExchangeEvent estMarketOrderReturn =
new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_MARKET_ORDER_EST, event.getData(), coinfloorAdapters.adaptEstimateMarketOrder(event.getData()));
addToEventQueue(estMarketOrderReturn);
break;
}
}
else if (jsonData.containsKey("notice")) {
if (jsonData.get("notice").equals("Welcome")) {
CoinfloorExchangeEvent welcomeEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.WELCOME, event.getData(), jsonData);
addToEventQueue(welcomeEvent);
serverNonce = (String) jsonData.get("nonce");
}
else if (jsonData.get("notice").equals("BalanceChanged")) {
CoinfloorExchangeEvent balancesChangedEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.USER_WALLET_UPDATE, event.getData(), coinfloorAdapters.adaptBalancesChanged(event.getData()));
addToEventQueue(balancesChangedEvent);
}
else if (jsonData.get("notice").equals("OrderOpened")) {
CoinfloorExchangeEvent orderOpenedEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.ORDER_ADDED, event.getData(), coinfloorAdapters.adaptOrderOpened(event.getData()));
addToEventQueue(orderOpenedEvent);
}
else if (jsonData.get("notice").equals("OrdersMatched")) {
CoinfloorExchangeEvent tradeEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.TRADE, event.getData(), coinfloorAdapters.adaptOrdersMatched(event.getData()));
addToEventQueue(tradeEvent);
}
else if (jsonData.get("notice").equals("OrderClosed")) {
CoinfloorExchangeEvent orderClosedEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.ORDER_CANCELED, event.getData(), coinfloorAdapters.adaptOrderClosed(event.getData()));
addToEventQueue(orderClosedEvent);
}
else if (jsonData.get("notice").equals("TickerChanged")) {
CoinfloorExchangeEvent tickerChangedEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.TICKER, event.getData(), coinfloorAdapters.adaptTickerUpdate(event.getData()));
addToEventQueue(tickerChangedEvent);
}
}
else {
log.warn("Exchange returned unexpected event: " + event.toString());