package com.cooleshow.base.websocket;


import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;
import java.nio.ByteBuffer;
import java.util.Map;

public class JWebSocketClient extends WebSocketClient {
    StringBuilder sb;
    public JWebSocketClient(URI serverUri, Map<String, String> httpHeaders) {
        super(serverUri, new Draft_6455(), httpHeaders);
    }

    @Override
    public void onOpen(ServerHandshake handshakedata) {
//        sb = new StringBuilder();
//        sb.append("onOpen at time：");
//        sb.append(new Date());
//        sb.append("服务器状态：");
//        sb.append(handshakedata.getHttpStatusMessage());
//        LOG.e("JWebSocketClient" + "onOpen:" + sb.toString());
    }

    @Override
    public void onMessage(String message) {
    }

    @Override
    public void onMessage(ByteBuffer bytes) {
//        LOG.e("JWebSocketClient" + "onMessage" + bytes.toString());
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {
//        sb = new StringBuilder();
//        sb.append("onClose at time：");
//        sb.append(new Date());
//        sb.append("\n");
//        sb.append("onClose info:");
//        sb.append(code);
//        sb.append(reason);
//        sb.append(remote);
//        LOG.e("JWebSocketClient" + "onClose：" + sb.toString());


    }

    @Override
    public void onError(Exception ex) {
//        sb = new StringBuilder();
//        sb.append("onError at time：");
//        sb.append(new Date());
//        sb.append("\n");
//        sb.append(ex);
//        LOG.e("JWebSocketClient" + "onError:" + sb.toString());
    }
}