private async void OnServerConnectionEstablished()

in Tools/ReceiverVLC/MainPage.xaml.cs [182:258]


        private async void OnServerConnectionEstablished(
            Windows.Networking.Sockets.StreamSocket socket)
        {
#if DBG_ENABLE_VERBOSE_LOGGING
            System.Diagnostics.Debug.WriteLine(
                "OnServerConnectionEstablished: server connection established");
#endif

            var receiver = new HoloLensForCV.SensorFrameReceiver(
                socket);

            try
            {
                while (true)
                {
                    HoloLensForCV.SensorFrame sensorFrame =
                        await receiver.ReceiveAsync();

#if DBG_ENABLE_VERBOSE_LOGGING
                    System.Diagnostics.Debug.WriteLine(
                        "OnServerConnectionEstablished: seeing a {0}x{1} image of type {2} with timestamp {3}",
                        sensorFrame.SoftwareBitmap.PixelWidth,
                        sensorFrame.SoftwareBitmap.PixelHeight,
                        sensorFrame.FrameType,
                        sensorFrame.Timestamp);
#endif

                    switch (sensorFrame.FrameType)
                    {
                        case HoloLensForCV.SensorType.VisibleLightLeftLeft:
                            _vlcLeftLeftContext.RawImage =
                                sensorFrame.SoftwareBitmap;

                            _vlcLeftLeftContext.ImageSourceNeedsUpdate = true;
                            break;

                        case HoloLensForCV.SensorType.VisibleLightLeftFront:
                            _vlcLeftFrontContext.RawImage =
                                sensorFrame.SoftwareBitmap;

                            _vlcLeftFrontContext.ImageSourceNeedsUpdate = true;
                            break;

                        case HoloLensForCV.SensorType.VisibleLightRightFront:
                            _vlcRightFrontContext.RawImage =
                                sensorFrame.SoftwareBitmap;

                            _vlcRightFrontContext.ImageSourceNeedsUpdate = true;
                            break;

                        case HoloLensForCV.SensorType.VisibleLightRightRight:
                            _vlcRightRightContext.RawImage =
                                sensorFrame.SoftwareBitmap;

                            _vlcRightRightContext.ImageSourceNeedsUpdate = true;
                            break;

                        default:
                            throw new Exception("invalid sensor frame type");
                    }

                    UpdateImages();
                }
            }
            catch (Exception exception)
            {
                // If this is an unknown status it means that the error is fatal and retry will likely fail.
                if (Windows.Networking.Sockets.SocketError.GetStatus(exception.HResult) ==
                    Windows.Networking.Sockets.SocketErrorStatus.Unknown)
                {
                    throw;
                }

                System.Diagnostics.Debug.WriteLine(
                    "Read stream failed with error: " + exception.Message);
            }
        }