package com.tsi.navi.websocket;

import android.util.Log;

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

import java.net.URI;

public class NaviWebsocketClient extends WebSocketClient {

    private static final String TAG = NaviWebsocketClient.class.getSimpleName();

    public NaviWebsocketClient(URI serverUri) {
        super(serverUri, new Draft_6455(), null, 5000);
        Log.e(TAG, "NaviWebsocketClient create: " + serverUri.toString());
    }

    @Override
    public void onOpen(ServerHandshake handshake) {
        Log.e(TAG, "onOpen: " + handshake.getHttpStatusMessage());
    }

    @Override
    public void onMessage(String message) {
        Log.e(TAG, "onMessage: " + message.length());
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {
        Log.e(TAG, "onClose: " + code + ", " + reason + ", " + remote);
    }

    @Override
    public void onError(Exception ex) {
        Log.e(TAG, "onError: " + ex.getMessage());
    }
}
