예제 #1
0
    private void ConnectServer()
    {
        if (m_CustomNetworkChannelHelper != null)
        {
            m_CustomNetworkChannelHelper.Shutdown();
        }
        if (m_NetworkChannel != null)
        {
            m_NetworkChannel.Close();
        }
        m_CustomNetworkChannelHelper = new ET_NetworkChannelHelper();
        m_NetworkChannel             = GameEntry.Network.CreateNetworkChannel("tcp" + m_ConnectTime++, GameFramework.Network.ServiceType.TcpWithSyncReceive, m_CustomNetworkChannelHelper);
        IPAddress iPAddress = IPAddress.Parse("192.168.31.32");

        //IPAddress iPAddress = IPAddress.Parse("129.28.170.32");
        m_NetworkChannel.Connect(iPAddress, SrvCfg.srvPort);
        //StartCoroutine(client.CheckNet());
    }
예제 #2
0
    protected override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
    {
        if (m_Channel == null)
        {
            return;
        }

        // 2秒后关闭连接(只是演示用的,实际中根据情况关闭连接)
        time += elapseSeconds;
        if (time > 2 && Demo8_SocketServer.isOpen)
        {
            Demo8_SocketServer.isOpen = false;
            m_Channel.Close();
        }
    }