Exemple #1
0
    public bool StartServer(int port, ConnectionType type)
    {
        Debug.Log("Network::StartServer called. port:" + port);

        // 리스닝 소켓을 생성합니다.
        try {
            // 도달을 보장하는 TCP통신을 시작합니다.
            if (type == ConnectionType.TCP ||
                type == ConnectionType.Both)
            {
                m_tcp = new TransportTcp();
                m_tcp.StartServer(port);
                m_tcp.RegisterEventHandler(OnEventHandling);
            }
            // 도달 보장이 필요 없는 UDP 통신을 시작합니다.
            if (type == ConnectionType.UDP ||
                type == ConnectionType.Both)
            {
                m_udp = new TransportUdp();
                m_udp.StartServer(port);
                m_udp.RegisterEventHandler(OnEventHandling);
            }
        }
        catch {
            Debug.Log("Network::StartServer fail.!");
            return(false);
        }

        Debug.Log("Network::Server started.!");

        m_isServer = true;

        return(LaunchThread());
    }