Giter Site home page Giter Site logo

gojong's Introduction

header

Gojong

[프로젝트 기간]

2022.04 ~ 2022.06

[기술 스택]

[아키텍처]

[프로젝트 내용]

리얼센스 카메라를 이용하여 키오스크 앞에 사람이 있는지 확인한 후 사람이 인식되면 시작되고 사라지면 다시 처음으로 돌아갑니다.
Google Dialogflow와 소켓 통신을 기반으로 스트리밍 기능을 추가해 이전 대화형 AI 김구보다 더 빠르고 정확하게 커뮤니케이션이 가능한 프로젝트입니다.
현재 덕수궁에서 전시되고 있습니다.

[프로젝트 투입 인원]

개발자 2, 디자이너 1

[나의 역할]

  • Google Dialogflow API 연동
  • 코드 결합 및 수정
  • 서버/클라이언트 소켓 통신
  • 스트리밍 기능 추가
  • 코드 리팩터링 및 최적화
  • 프로젝트 QA
  • 프로젝트 유지보수
  • 클라이언트와 지속적으로 면담 및 요구사항 수정

[핵심 코드]

서버와 클라이언트의 소켓통신으로 주고받은 정보를 기준으로 프로젝트가 진행됩니다.

서버 생성 코드

    ```
    public void ServerCreate()
    {
        clients = new List<ServerClient>();
        disconnectList = new List<ServerClient>();

        try
        {
            int port = PortInput.text == "" ? 7777 : int.Parse(PortInput.text);
            server = new TcpListener(IPAddress.Any, port);
            server.Start();

            StartListening();
            serverStarted = true;
            //Chat.instance.ShowMessage($"서버가 {port}에서 시작되었습니다.");
        }
        catch (Exception e)
        {
            Chat.instance.ShowMessage($"Socket error: {e.Message}");
        }
    }
    ```

서버와 연결되는 클라이언트 코드

    ```
    public void ConnectedToServer()
    {
        if (socketReady) return;

        string ip = IPInput.text == "" ? "127.0.0.1" : IPInput.text;
        int port = PortInput.text == "" ? 7777 : int.Parse(PortInput.text);

        try
        {
            socket = new TcpClient(ip, port);
            stream = socket.GetStream();
            writer = new StreamWriter(stream);
            reader = new StreamReader(stream);
            socketReady = true;
        }
        catch (Exception e)
        {
            Chat.instance.ShowMessage($"소켓에러 : {e.Message}");
        }
    }
    ```

서버에서 받아온 응답을 기준으로 애니메이션과 오디오 재생하는 코드

    ```
    public void ShowMessage(string data)
    {
        Debug.Log(data);
        if (data.Contains(":"))
        {
            string[] dataArr = data.Split(':');

            dataNum = int.Parse(dataArr[1].Trim());
            Debug.Log(dataNum);
            ChatText.text += ChatText.text == "" ? data : "\n" + data;
        }
        // 사람 없을 때
        if(dataNum == 1000)
            state = 1000;
            
        // 사람 있을 때
        else if(dataNum == 2000) 
            state = 2000;

        if(state == 1000)
            dataNum = 0;

        else if(state == 2000) 
        {
            if (!df2.isAnimation) 
            { 
                // 받아온 dataNum을 통해서 애니메이션과 오디오 플레이
                df2.playAnimation(dataNum);                
            }
        }
        Fit(ChatText.GetComponent<RectTransform>());
        Fit(ChatContent);
        Invoke("ScrollDelay", 0.03f);
    }
    ```

Footer

gojong's People

Contributors

gongdolgun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.