Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
818 views
in Technique[技术] by (71.8m points)

socket.io - SocketIOClient c# send base 64

I'm trying to send thumbs image from my c# application to Node using socket.io client for c#

   private async Task getImagefiles()
        {
            DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "pptImages");

            Byte[] fileThumb;
            string idThumb;
            int totalFiles= di.GetFiles().Length;

            try
            {

                for (int count = 1; count <= totalFiles; count++)
                {
                    fileThumb = File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + "pptImages\slide" + count + ".png");
                    idThumb = count.ToString();
                    pptThumbs.Add(idThumb, fileThumb);
                    pptThumbs2.Add(idThumb, JsonConvert.SerializeObject(fileThumb));
                    string result = JsonConvert.SerializeObject(fileThumb);
                    Globals.socket.EmitAsync("slideThumbs", JObject.FromObject(new
                    {
                        tokenE = Globals.tokenE,
                        idSlide = count,
                        thumb = result
                    }));
                    Thread.Sleep(300);
                }
                
              

            }
            catch (Exception err){

                Console.WriteLine(err.Message);
                }

          


        }

From node result is invalid Payload randomly.

server side is only one conole log

        socket.on('slideThumbs', async(dataJson) => {
            if (dataJson)
            {
                console.log(dataJson);   
            }

With arrayBuffer I don't have this problem, but in the client I can't get the image to render


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...