Beispiel #1
0
        public static void SendMessage(NativeArray <byte> nativeRawBytes, int type, int width, int height) //only used for image
        {
#if UNITY_WEBGL
            if (_socket == null || !linkFlag)
            {
                return;
            }
            jpegEncoder.doNativeEncoding(nativeRawBytes, width, height);
            byte[] image = jpegEncoder.GetBytes();
            PackAndSendWebGL(image, (int)DataType.Screenshot);
            screenFlag = false;
#else
            if (m_client == null)
            {
                return;
            }
            UPRMessage sample = new UPRMessage
            {
                nativeRawBytes = nativeRawBytes,
                type           = type,
                width          = width,
                height         = height
            };
            lock (m_sampleQueue)
            {
                m_sampleQueue.Enqueue(sample);
            }
#endif
        }
        private static void DoSendMessage()
        {
            while (true)
            {
                try
                {
                    if (m_sendThread == null)
                    {
                        Debug.Log("<color=#ff0000>Package m_sendThread null</color>");
                        return;
                    }
                    if (m_sampleQueue.Count > 0)
                    {
                        while (m_sampleQueue.Count > 0)
                        {
                            UPRMessage s = null;
                            lock (m_sampleQueue)
                            {
                                s = m_sampleQueue.Dequeue();
                            }
                            switch (s.type)
                            {
                            case 0:

#if UNITY_2018_2_OR_NEWER
                                jpegEncoder.doNativeEncoding(s.nativeRawBytes, s.width, s.height);
#else
                                jpegEncoder.doEncoding(s.rawBytes, s.width, s.height);
#endif

                                byte[] image = jpegEncoder.GetBytes();
                                screenFlag = false;
                                PackAndSend(image, (int)DataType.Screenshot);
                                break;

                            case 1:
                                PackAndSend(s.rawBytes, (int)DataType.PSS);
                                break;

                            case 2:
                                PackAndSend(s.rawBytes, (int)DataType.Device);
                                break;
                            }
                        }
                    }
                    Thread.Sleep(100);
                }
                catch (ThreadAbortException e)
                {
                    Debug.Log(e);
                }
                catch (Exception e)
                {
                    Debug.Log(e);
                    Close();
                }
            }
        }
 public static void SendMessage(UPRMessage sample)
 {
     if (m_client == null)
     {
         return;
     }
     lock (m_sampleQueue)
     {
         m_sampleQueue.Enqueue(sample);
     }
 }
        public static void SendMessage(NativeArray <byte> nativeRawBytes, int type, int width, int height)
        {
            UPRMessage sample = new UPRMessage
            {
                nativeRawBytes = nativeRawBytes,
                type           = type,
                width          = width,
                height         = height
            };

            if (m_client == null)
            {
                return;
            }
            lock (m_sampleQueue)
            {
                m_sampleQueue.Enqueue(sample);
            }
        }
Beispiel #5
0
        public static void SendMessage(byte[] rawBytes, int type, int width, int height)
        {
#if UNITY_WEBGL
            if (_socket == null || !linkFlag)
            {
                return;
            }
            switch (type)
            {
            case 0:
                jpegEncoder.doEncoding(rawBytes, width, height);
                byte[] image = jpegEncoder.GetBytes();
                PackAndSendWebGL(image, (int)DataType.Screenshot);
                screenFlag = false;
                break;

            case 1:
                PackAndSendWebGL(rawBytes, (int)DataType.PSS);
                break;

            case 2:
                PackAndSendWebGL(rawBytes, (int)DataType.Device);
                break;
            }
#else
            UPRMessage sample = new UPRMessage
            {
                rawBytes = rawBytes,
                type     = type,
                width    = width,
                height   = height
            };
            if (m_client == null)
            {
                return;
            }
            lock (m_sampleQueue)
            {
                m_sampleQueue.Enqueue(sample);
            }
#endif
        }