Issue with Notification and Disconnect - rxandroidble

We are trying to upgrade existing app with your framework, other things are working fine like connection/read/write however we are facing issues with Notification/Disconnect
Can you please guide for following scenarios:-
Need call back for disconnection
Notification not working we are not able to receive any notification alert
Is there any method to check characteristics of devices, as we have different devices and some characteristics are not present in all devices, when we try to read/write non present chacraterstics on devices, it throws exception and app crashes
Code :-
connection.writeDescriptor(
Defs.SVC_AUTOMATIONIO_UUID,
Defs.CHAR_AUTOMATION_IO,
Defs.DESC_CLIENT_CHAR_CONFIGURATION_UUID,
BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE
)
.subscribe(
this::onWriteSuccess,
this::onWriteFailure
);
connection.setupNotification(iCharUuid)
.flatMap(notificationObservable -> notificationObservable)
.subscribe(
this::onNotificationReceived,
this::onConnectionFailure
);
Thanks
Swayam

In general you don't have to write descriptor manually to enable notifications. The library does it for you.
Try: (example)
rxBleConnection.setupNotification(Defs.DESC_CLIENT_CHAR_CONFIGURATION_UUID)
.flatMap(notificationObservable -> notificationObservable)
.subscribe(this::onNotificationReceived, this::onNotificationSetupFailure);
In order to get callback for disconnection: (example)
You can observe onError from establishConnection method.
You can setup connection status observable
bleDevice.observeConnectionStateChanges().subscribe(this::onConnectionStateChange);
To check characteristics you can go with service discovery: (example)
bleDevice.establishConnection(this, false)
.flatMap(RxBleConnection::discoverServices)
.first() // Disconnect automatically after discovery
.subscribe(this::processDiscoveredServices, this::onConnectionFailure);

Related

Missing videoTrack in a multitrack stream in Ant media server 2.4.1

We have a Multitrack web conference implementation using AMS 2.4.1 version. Its working great for our use case, except in one scenario. When there are N (< 3) number of users and they on there camera simultaneously, then few remote users are not rendered as we don't receive the video tracks for those users in newStreamAvailable. We only receive the audio track for those users. We are able to reproduce this quite frequently.
As a backup, I am trying to poll AMS using getTrackList with the main track Id to get all available streams, but I am not getting any message trackList
var jsCmd =
{
command : "getTrackList",
streamId : streamId, // this is roomId or main track id
token : token
}
Any insight would be helpful.
Thanks,
We were able to resolve the issue, posting here to help anyone who might be facing a similar issue.
With push notifications from the server, we might encounter issues when for some reason push operation doesn't succeed. In that case, it's better to have a backup plan to pull from the server and sync.
The Ant Media Server suggests pulling the server periodically for the room info. The server will respond with active streams and the application should synchronize.
For reference, please refer to following link https://resources.antmedia.io/docs/webrtc-websocket-messaging-reference

Firestore Timeout [duplicate]

We are building a real-time chat app using Firestore. We need to handle a situation when Internet connection is absent. Basic message sending code looks like this
let newMsgRef = database.document(“/users/\(userId)/messages/\(docId)“)
newMsgRef.setData(payload) { err in
if let error = err {
// handle error
} else {
// handle OK
}
}
When device is connected, everything is working OK. When device is not connected, the callback is not called, and we don't get the error status.
When device goes back online, the record appears in the database and callback triggers, however this solution is not acceptable for us, because in the meantime application could have been terminated and then we will never get the callback and be able to set the status of the message as sent.
We thought that disabling offline persistence (which is on by default) would make it trigger the failure callback immediately, but unexpectedly - it does not.
We also tried to add a timeout after which the send operation would be considered failed, but there is no way to cancel message delivery when the device is back online, as Firestore uses its queue, and that causes more confusion because message is delivered on receiver’s side, while I can’t handle that on sender’s side.
If we could decrease the timeout - it could be a good solution - we would quickly get a success/failure state, but Firebase doesn’t provide such a setting.
A built-in offline cache could be another option, I could treat all writes as successful and rely on Firestore sync mechanism, but if the application was terminated during the offline, message is not delivered.
Ultimately we need a consistent feedback mechanism which would trigger a callback, or provide a way to monitor the message in the queue etc. - so we know for sure that the message has or has not been sent, and when that happened.
The completion callbacks for Firestore are only called when the data has been written (or rejected) on the server. There is no callback for when there is no network connection, as this is considered a normal condition for the Firestore SDK.
Your best option is to detect whether there is a network connection in another way, and then update your UI accordingly. Some relevant search results:
Check for internet connection with Swift
How to check for an active Internet connection on iOS or macOS?
Check for internet connection availability in Swift
As an alternatively, you can check use Firestore's built-in metadata to determine whether messages have been delivered. As shown in the documentation on events for local changes:
Retrieved documents have a metadata.hasPendingWrites property that indicates whether the document has local changes that haven't been written to the backend yet. You can use this property to determine the source of events received by your snapshot listener:
db.collection("cities").document("SF")
.addSnapshotListener { documentSnapshot, error in
guard let document = documentSnapshot else {
print("Error fetching document: \(error!)")
return
}
let source = document.metadata.hasPendingWrites ? "Local" : "Server"
print("\(source) data: \(document.data() ?? [:])")
}
With this you can also show the message correctly in the UI

In Meteor Methods this.connection is always undefined

I am trying to implement some methods for a DDP API, for use with a C# remote client.
Now, I want to be able to track the connection to implement some type of persistent session, to this end, id hope to be able to use the session id given by DDP on connection, example:
{
"msg": "connected",
"session": "CmnXKZ34aqSnEqscR"
}
After reading the documentation, I see that inside meteor methods, I can access the current connection using "this.connection", however, I always get an undefined "this.connection".
Was it removed? If so, how can i access it now?
PS: I dont want to login as a user and access this.userId, since the app I want to create should not login, but actually just get a document id and do work associated with that, including changes to other collections, but all, regarding ONLY this id, and I dont want to have to include this id every time I call a function, since, this could possibly lead security problems if anyone can just send any id. The app would ideally do a simple login, then associate token details with his "session".
Changing from:
() => { this.connection; }
to:
function() { this.connection; }
solves the problem from me. Based on a comment in the accepted answer.
The C# client on github has a few bugs with it as it doesn't follow the DDP spec exactly. When you send commands to it to connect and run a call, it usually sends the '.call' too soon.
The method does work if you do it this way with this.connection on the server side Meteor method.
You need to make sure you send the method calls after you know that you are actually connected. This is what works at least with Meteor 0.8.2
I was using a file named ".next.js" to force meteor to use the newest unsupported javascript spec using a package.
Somehow this messed it up. Changed back to default javascript and it now works.
Thank you :)
init.coffee
Meteor.startup ->
# client init
if Meteor.isClient
Meteor.call "init"
methods.coffee
Meteor.methods
init: ->
console.log #connection.httpHeaders.host
it's that easy...

Unable to Receive Pushes in client application after Registration in BB10 Webworks

My question is similar to BlackBerry push client application subscription but still i have doubts in that ..plz clarify.My doubt is When i tried with sample Push Initiator which comes with Push SDK and Sample Push-enabled application[Push Capture] from github i can Receive Pushes in that sample application.But when i try the same logic in My own client application i am not receiving Pushes..
Steps I followed:
Registered with Push service and got Confirmation mail with AppID,Password and PPG url.
With those details i set to receive Pushes like:Called the create function and createChannel,success callback was called and it returned device token also.
But still i am not receiving Pushes in my application.Plz help where i am lagging.
Question:
How Pushes differentiate the client app and devices while sending Pushes.
NOTE:i used the same AppID which i used for sample app.
when i called create function and createChannel,success callback was called and it returned device token also. When i received Push,onInvoke event was called and action was bb.action.PUSH which denotes we received a Push..Since i didnot add Notifications to Hub i didnot recognize previously.
Also we cannot use same AppID for different applications.It will create problem

How to send push notifications to more than one platform using Redth PushSharp library?

I've been using Redth/PushSharp code to implement server side push for both Android and iPhone.
Using the following code:
foreach (Receipient in iOSUsers)
{
push.QueueNotification(NotificationFactory.Apple()
.ForDeviceToken(APNS_Device_Token_Of_Receipient)
.WithAlert("Alert!")
.WithSound("default")
.WithBadge(2));
}
foreach (Receipient in GCMUsers)
{
push.QueueNotification(NotificationFactory.AndroidGcm()
.ForDeviceRegistrationId(GCM_Device_Token_Of_Receipient)
.WithCollapseKey("NONE")
.WithJson("Alert!"));
}
My problem is that I'm able to send only to one platform at a time, the code above sends only to iPhone, and if the first loop is disabled than only Android users will get the push message.
Any clue?
I can add additional code if needed.
Thanks!
Have a look at
.WithExpiry()
to specify a expiration date for the message you sent.
I created a windows service that gets the list of ios users and android users and for each calls an instance of the pushbroker object and processes as you have above. You'll have multiple threads processing all ios and android.

Resources