Beispiel #1
0
        void handlePictureMessage(BasicDeliverEventArgs e, Dictionary <string, string> headers)
        {
            headers.TryGetValue("senderDeviceId", out var pictureSenderDeviceId);
            headers.TryGetValue("senderOwnerName", out var pictureSenderOwnerName);
            return;

            // still_todo: implement this on VM with event raising
#if __ANDROID__
            Helper.RunOnUiThread(() => MainActivity.PictureMessages.Add(PictureMessage.FromRabbitMessage(e.Body.ToArray(), pictureSenderDeviceId, pictureSenderOwnerName)));
#elif WINDOWS_UWP
            var status = await Helper.GetDoNotDisturbStatusAsync();

            if (status.DoNotDisturb)
            {
                return;
            }
            if (Helper.IsDisplayOff())
            {
                Helper.WakeupApp();
            }
            await AppServiceBridge.SendData(new ValueSet()
            {
                [AppServiceConstants.PictureData]            = e.Body.ToArray(),
                [AppServiceConstants.PictureSenderDeviceId]  = pictureSenderDeviceId,
                [AppServiceConstants.PictureSenderOwnerName] = pictureSenderOwnerName,
            });
#elif __IOS__
            // still_TODO
#endif
            //Helper.Vibrate();
            return;
        }
Beispiel #2
0
        public static void SendMedia(byte[] data, Device targetDevice)
        {
            try
            {
#if WINDOWS_UWP
                if (Helper.IsForegroundApp)
                {
                    AppServiceBridge.SendData(new ValueSet()
                    {
                        [AppServiceConstants.WalkieTalkieData]           = data,
                        [AppServiceConstants.WalkieTalkieSenderDeviceId] = targetDevice.ID,
                    }).Forget();
                    return;
                }
#endif
                if (IsConnected) // still_TODO should this also work when charging / not connected?
                {
                    var props = rabbitChannel.CreateBasicProperties();
                    props.Expiration   = TimeSpan.FromMinutes(1).TotalMilliseconds.ToString();
                    props.ContentType  = "audio/aac";
                    props.DeliveryMode = 1; // non-persistent
                    props.Headers      = new Dictionary <string, object>()
                    {
                        { "senderDeviceId", Settings.Smartwatch.ID },
                        { "senderOwnerName", Settings.Smartwatch.Owner.FullName },
                        { "aucoboClass", "" /*Constants.WALKIE_TALKIE_BUTTON_ID*/ },
                    };

                    rabbitChannel.BasicPublish("", targetDevice.ID, props, data);
                }
                return;
            }
            catch (Exception e)
            {
                //still_todo: implement if needed
                //Logger.Error("RabbitMQHelper.SendMedia: " + e);
            }
            //still_todo: implement if needed
            //Helper.ShowToast("Sending audio message failed");
        }