Skip to content

Commit 0732ba3

Browse files
committed
- client discovery improvements
- minor VoIP improvements
1 parent 7b22a4a commit 0732ba3

File tree

4 files changed

+57
-52
lines changed

4 files changed

+57
-52
lines changed

Spixi/App.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ protected override void OnResume()
207207

208208
NetworkClientManager.wakeReconnectLoop();
209209
StreamClientManager.wakeReconnectLoop();
210+
PresenceList.forceSendKeepAlive = true;
210211

211212
// Popup the lockscreen if necessary
212213
// Allow a 5 second cooldown after unlock
@@ -219,7 +220,6 @@ protected override void OnResume()
219220
var lockPage = new LockPage(true);
220221
lockPage.authSucceeded += onUnlock;
221222
MainPage.Navigation.PushModalAsync(lockPage);
222-
PresenceList.forceSendKeepAlive = true;
223223
return;
224224
}
225225

@@ -229,7 +229,6 @@ protected override void OnResume()
229229
p.onResume();
230230
}
231231
OfflinePushMessages.resetCooldown();
232-
PresenceList.forceSendKeepAlive = true;
233232
}
234233

235234
protected override void OnSleep()

Spixi/Network/StreamProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ private static void handleAppRequest(byte[] messageId, Address sender_address, A
588588
{
589589
if (VoIPManager.onReceivedCall(friend, app_data.sessionId, app_data.data))
590590
{
591-
Node.addMessageWithType(messageId, FriendMessageType.voiceCall, sender_address, 0, "");
591+
Node.addMessageWithType(app_data.sessionId, FriendMessageType.voiceCall, sender_address, 0, "");
592592
}
593593
UIHelpers.refreshAppRequests = true;
594594
}
@@ -599,7 +599,7 @@ private static void handleAppRequest(byte[] messageId, Address sender_address, A
599599
Logging.error("App with id {0} is not installed.", app_id);
600600
}
601601
}
602-
Node.addMessageWithType(messageId, FriendMessageType.appSession, sender_address, 0, app_data.appId);
602+
Node.addMessageWithType(app_data.sessionId, FriendMessageType.appSession, sender_address, 0, app_data.appId);
603603

604604
});
605605
}

Spixi/Platforms/Android/SPlatformUtils.cs

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using Android.App;
22
using Android.Content;
33
using Android.Media;
4-
using Android.OS;
5-
using AndroidX.Core.View;
64
using IXICore.Meta;
75
using SPIXI;
86
using SPIXI.Interfaces;
@@ -11,6 +9,8 @@ namespace Spixi
119
{
1210
public class SPlatformUtils
1311
{
12+
static object ringtoneLock = new object();
13+
1414
static MediaPlayer? ringtone = null;
1515
static MediaPlayer? dialtonePlayer = null;
1616

@@ -43,68 +43,74 @@ public static string getHtmlPath()
4343

4444
public static void startRinging()
4545
{
46-
if (ringtone != null)
46+
lock (ringtoneLock)
4747
{
48-
return;
49-
}
50-
51-
try
52-
{
53-
bool ring = true;
54-
55-
NotificationManager nm = (NotificationManager)MainActivity.Instance.GetSystemService(Context.NotificationService)!;
56-
InterruptionFilter int_filter = nm.CurrentInterruptionFilter;
57-
if (int_filter != InterruptionFilter.Priority && int_filter != InterruptionFilter.All)
48+
if (ringtone != null)
5849
{
59-
ring = false;
50+
return;
6051
}
61-
6252

63-
AudioManager am = (AudioManager)MainActivity.Instance.GetSystemService(Context.AudioService)!;
64-
if (am.RingerMode != RingerMode.Normal)
53+
try
6554
{
66-
ring = false;
55+
bool ring = true;
56+
57+
NotificationManager nm = (NotificationManager)MainActivity.Instance.GetSystemService(Context.NotificationService)!;
58+
InterruptionFilter int_filter = nm.CurrentInterruptionFilter;
59+
if (int_filter != InterruptionFilter.Priority && int_filter != InterruptionFilter.All)
60+
{
61+
ring = false;
62+
}
63+
64+
65+
AudioManager am = (AudioManager)MainActivity.Instance.GetSystemService(Context.AudioService)!;
66+
if (am.RingerMode != RingerMode.Normal)
67+
{
68+
ring = false;
69+
}
70+
71+
MainActivity.Instance.VolumeControlStream = Android.Media.Stream.Ring;
72+
73+
if (ring)
74+
{
75+
ringtone = playSoundFromAssets("sounds/default_ringtone.mp3");
76+
ringtone.Looping = true;
77+
ringtone.Start();
78+
}
6779
}
68-
69-
MainActivity.Instance.VolumeControlStream = Android.Media.Stream.Ring;
70-
71-
if (ring)
80+
catch (Exception e)
7281
{
73-
ringtone = playSoundFromAssets("sounds/default_ringtone.mp3");
74-
ringtone.Looping = true;
75-
ringtone.Start();
82+
Logging.error("Exception occurred in startRinging: " + e);
83+
ringtone = null;
7684
}
7785
}
78-
catch (Exception e)
79-
{
80-
Logging.error("Exception occurred in startRinging: " + e);
81-
ringtone = null;
82-
}
8386
}
8487

8588
public static void stopRinging()
8689
{
87-
if (ringtone == null)
90+
lock (ringtoneLock)
8891
{
89-
return;
90-
}
92+
if (ringtone == null)
93+
{
94+
return;
95+
}
9196

92-
try
93-
{
94-
if (ringtone.IsPlaying)
97+
try
9598
{
96-
ringtone.Stop();
99+
if (ringtone.IsPlaying)
100+
{
101+
ringtone.Stop();
102+
}
103+
ringtone.Release();
104+
}
105+
catch (Exception e)
106+
{
107+
Logging.error("Exception occurred while stopping the ringtone: " + e);
108+
}
109+
finally
110+
{
111+
ringtone = null;
112+
MainActivity.Instance.VolumeControlStream = Android.Media.Stream.NotificationDefault;
97113
}
98-
ringtone.Release();
99-
}
100-
catch (Exception e)
101-
{
102-
Logging.error("Exception occurred while stopping the ringtone: " + e);
103-
}
104-
finally
105-
{
106-
ringtone = null;
107-
MainActivity.Instance.VolumeControlStream = Android.Media.Stream.NotificationDefault;
108114
}
109115
}
110116

Spixi/VoIP/VoIPManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static void initiateCall(Friend friend)
5858
string codecs = String.Join("|", SSpixiCodecInfo.getSupportedAudioCodecs());
5959

6060
var sm = StreamProcessor.sendAppRequest(friend, "spixi.voip", currentCallSessionId, Encoding.UTF8.GetBytes(codecs), "spixi.voip");
61-
Node.addMessageWithType(sm.id, FriendMessageType.voiceCall, friend.walletAddress, 0, "", true, null, 0, false);
61+
Node.addMessageWithType(currentCallSessionId, FriendMessageType.voiceCall, friend.walletAddress, 0, "", true, null, 0, false);
6262
((SpixiContentPage)Application.Current.MainPage.Navigation.NavigationStack.Last()).displayCallBar(currentCallSessionId, SpixiLocalization._SL("global-call-dialing") + " " + friend.nickname + "...", 0);
6363

6464
aquirePowerLocks();

0 commit comments

Comments
 (0)