예제 #1
0
        public void SelfClient_ReceivedMsg(System.Net.Sockets.Socket socket, byte[] buffer, int size)
        {
            try
            {
                string recvText = Encoding.UTF8.GetString(buffer, 0, size);
                JsonData[] recvJsons = JsonData.ParseStream(recvText);

                foreach (JsonData per in recvJsons)
                {
                    TransPackage recvPackage = JsonData.ConvertToInstance<TransPackage>(per);
                    DealPackage(recvPackage);
                }

                return;
            }
            catch
            {
                if (partsBuffer == null)
                {
                    partsBuffer = new MemoryStream();
                    partsBuffer.Write(buffer, 0, size);
                }
                else
                {
                    partsBuffer.Write(buffer, 0, size);

                    try
                    {
                        string bufferStr = Encoding.UTF8.GetString(partsBuffer.ToArray());
                        if (JsonData.TryParseStream(bufferStr, out JsonData[] jsons))