Exemplo n.º 1
0
    public override void Init()
    {
        buffer = new ByteBuffer(cBufferSize);
        // 由于无法控制socket对缓冲区的写入过程, 所以无法进行动态扩容, 直接将初始值设置的大一些
        tempBuffer = new ByteBuffer(cBufferSize);
        sendBuffer = new ByteBuffer(cBufferSize);

        recvPool = new NetPool();
        sendPool = new NetPool();

        timeoutPacket.Clear();

        recvThread              = new Thread(new ThreadStart(OnSocketReceive));
        recvThread.Name         = "DIDANetmanager_Recv";
        recvThread.IsBackground = false;
        recvThread.Priority     = System.Threading.ThreadPriority.Normal;
        recvThread.Start();

        sendThread              = new Thread(new ThreadStart(OnSocketSend));
        sendThread.Name         = "DIDANetmanager_Send";
        sendThread.IsBackground = false;
        sendThread.Priority     = System.Threading.ThreadPriority.Normal;
        sendThread.Start();

        Volatile.Write(ref isConnected, false);
        hasLogined = false;
    }
Exemplo n.º 2
0
    public void Init()
    {
        lengthEncode  = LengthEncoding.Encode;
        lengthDecode  = LengthEncoding.Decode;
        messageEncode = MessageEncoding.Encode;
        messageDecode = MessageEncoding.Decode;

        recvPool = new NetPool();
        sendPool = new NetPool();
    }
Exemplo n.º 3
0
        protected override void OnLoadFinish()
        {
            pool    = new NetPool();
            logList = new List <NetMetaInfo>();

            logTemplate = panel.transform.Find("ScrollView/Viewport/Content/ItemTemplate").gameObject;

            scrollRect = panel.transform.Find("ScrollView").GetComponent <ScrollRect>();


            logTemplate.SetActive(false);

            btnClear = panel.transform.Find("BtnClear").gameObject;

            btnClear.GetComponent <Button>().onClick.AddListener(() =>
            {
                ClearAllLogs();
            });

            btnStart = panel.transform.Find("BtnStart").gameObject;
            btnStart.GetComponent <Button>().onClick.AddListener(() =>
            {
                StartLog();
            });

            btnStop = panel.transform.Find("BtnStop").gameObject;
            btnStop.GetComponent <Button>().onClick.AddListener(() =>
            {
                StopLog();
            });


            btnCopy = panel.transform.Find("BtnCopy").GetComponent <Button>();
            btnCopy.onClick.AddListener(() =>
            {
                StringBuilder builder = new StringBuilder();
                foreach (var info in logList)
                {
                    builder.AppendLine(GetPrintStr(info));
                }

                EditorInterface.CopyToClipboard(builder.ToString());
            });

            recording = panel.transform.Find("Recording").GetComponent <Image>();

            this.cache.AddTemplate(TEMPLATE_ITEM_STR, logTemplate);
        }