Realtime Database .net

Backendless Version (3.x / 5.x, Online / Managed / Pro )

latest cloud backend

Client SDK (REST / Android / Objective-C / Swift / JS )

Xamarin.Forms App with Backendless.NET Nuget V6.2.0 (iOS+Android same behavior)

Application ID

852EE6BB-B3FF-A610-FF25-F064DAE8E300

Expected Behavior

  1. Implemented the Realtime Event Listener for AddCreateListener and AddUpdateListener
  2. Create a new Database entry from the app
  3. EventListener should trigger the defined event

Actual Behavior

  1. When the database entry create/update is done in the Backendless UI Data Browser, the code executes as expected
  2. When the database entry create/update is done from the REST-Console nothing happens
  3. Same for database create/update from client-app is not executed

Reproducible Test Case

BackendlessAPI.Backendless.Data.Of().RT().AddCreateListener(whereClause: $“Id = ‘{CurrentGame.objectId}’”, callback: newObject =>
{
Debug.WriteLine($“Created Object {newObject.Id}”);
Device.BeginInvokeOnMainThread(() => {
AllScores.Insert(0, newObject);
});
});

Hello, @Janis .

I have checked your code. It takes some time (about 5 seconds) to initialize RT in .NET.
Also, your code is not tied to any table - it won’t work.

Try the following code:

public void EnableRT( Object sender, EventArgs ea )
{
  IEventHandler<Person> eventHandler = Backendless.Data.Of<Person>().RT();
  Boolean CheckObjectCreation = false;
  Backendless.RT.AddConnectListener( async () =>
  {
    if( !CheckObjectCreation )
    {
      await Backendless.Data.Of<Person>().SaveAsync( new Person( "Joe", 21 ) );
      CheckObjectCreation = true;
    }
  } );

  Backendless.RT.AddConnectErrorListener( ( fault ) =>
  {
    Device.BeginInvokeOnMainThread( async () =>
    {
      await DisplayAlert( "Error", "Connection cannot be established " + fault.Message, "Ok" );
    } );
  } );

  eventHandler.AddCreateListener( createdObject =>
  {
    Device.BeginInvokeOnMainThread( async () =>
    {
      await DisplayAlert( "Event", $"Person object has been created. Object id: {createdObject.ObjectId}", "Ok" );
    } );
  } );
  ambiguousButton.IsEnabled = false;
}

And add the following code to your xaml file:

    <Button x:Name="ambiguousButton" Text="Enable real-time database"
            Clicked="EnableRT"/>

When you click on this button, your RT will begin to initialize. After the initialization is complete, a “Person” object will be created in the table, and you will receive a corresponding message. All subsequent creation of objects in this table will trigger this event.

Best regards, Nikita.

Hi Nikita,
yes that’s excactly what I’ve did in my application. Triggering the event handler (e.g. AddCreateListener) from the Backendless UI Console works nice!
But when I create a new object from Backendless REST-Console or Client-App (Xamarin.Forms iOS and Android) this event does not get raised on the receiver :frowning:

Hi @Janis .

Have you tried using the code I provided?
It is very strange. I checked this case - everything worked for me. Can you provide a minimal reproducible example?

Regards, Nikita.

Hi Nikita,
sure I’ve prepared a simple demo app with basic RT-Data features.
During development of the code I realized it works stable and fast with the Person Database! Awesome!

https://bitbucket.org/JanisTheuer/rtdata/src/master/
All the required RT-Code sits in the file MainVM.cs

But then I checked with my real customized database-scheme and it stopped immediately :frowning:
I identified the column “GeoPoint” in my table stops the expected result of RT.

To show the behavior in the demo app, simply add another property in the Person-Model like:

public Point GeoPoint { get; set; }

and create an object with this property set to real coordinates (not “null” !).
When it is null, it works just fine. That was the real reason why it behaves so strange on my side (as described in my first message) because I don’t enter a POINT from the Backendless UI, but automatically from my code when saving objects.

Maybe we can nail the issue down with this information?

Best regards,
Janis

Hello, @Janis.

Hi, we will look at this problem in more detail, I’ll let you know the results!

Regards, Nikita.

Hello again, @Janis.

We researched this issue. An error has occurred in the Real-Time service for .NET-SDK. Ticket BKNDLSS-24158 has been created.

Best regards, Nikita.