package org.iotivity.bridge.homeserver.handler.client;

import org.iotivity.OCClientResponse;
import org.iotivity.OCQos;
import org.iotivity.OCResponseHandler;
import org.iotivity.OCStatus;
import org.iotivity.bridge.homeserver.BridgeServerActivity;
import org.iotivity.bridge.homeserver.model.Light;
import org.iotivity.oc.OcCborEncoder;
import org.iotivity.oc.OcRemoteResource;
import org.iotivity.oc.OcUtils;

public class PutLightResponseHandler implements OCResponseHandler {

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

    private BridgeServerActivity activity;
    private OcRemoteResource resource ;

    public PutLightResponseHandler(BridgeServerActivity activity, OcRemoteResource resource) {
        this.activity = activity;
        this.resource = resource ;
    }

    @Override
    public void handler(OCClientResponse response) {
        activity.msg("PUT "+resource.getUri()+" Response Handler: Code = "+response.getCode().toString());
        if(response.getCode() != OCStatus.OC_STATUS_CHANGED && response.getCode() != OCStatus.OC_STATUS_CREATED) {
            activity.showErrorDialog("PUT "+resource.getUri()+" Response Handler Error",
                    "Result Code = " + response.getCode().toString());
            activity.printLine();
            return;
        }

        activity.printLine();
        activity.showResultDialog("PUT "+resource.getUri()+" Response Handler Result",
                "Result Code = " + response.getCode().toString());


    }
}
