package net.northking.cctp.mobile.util;

import io.netty.buffer.ByteBuf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.websocket.CloseReason;
import javax.websocket.RemoteEndpoint;
import javax.websocket.Session;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;

public class WSUtils {
    private static final Logger logger = LoggerFactory.getLogger(WSUtils.class);


    public static void sendText(RemoteEndpoint.Basic remoteEndpoint, String msg, String deviceId) {
        try {
            remoteEndpoint.sendText(msg);
        } catch (IOException e) {
            logger.warn("web端session已经断开",e);
        }

    }


    public static void sendBytes(RemoteEndpoint.Basic basicRemote, ByteBuffer data, String deviceId) {
        try {
            basicRemote.sendBinary(data);
        } catch (IOException e) {
            logger.warn("web端session已经断开",e);
        }
    }
}
