package com.yeejoin.amos.kgd.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.net.Socket;

/**
 * @Author: xl
 * @Description:
 * @Date: 2023/10/10 16:21
 */
public class ClientHandler implements Runnable {

    private static final Logger log = LoggerFactory.getLogger(ClientHandler.class);

    private Socket socket;

    public ClientHandler(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            log.info("Received message from client: ");
            // 获取输入流和输出流
            InputStream inputStream = socket.getInputStream();
            // 处理客户端请求,逻辑写到这⬇⬇⬇⬇⬇⬇⬇


            log.info("Received message from client: ");
            // 关闭连接
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}