TCP server client OR SQL dependency NOTIFICATION

ST.7899ST.7899 USMember ✭✭
edited November 19 in Xamarin.Forms
my question is more than i need a little bit of the community experience.

i have a project that works on Android and desktop application

(Engineer from Android side, and Agent from computer side)

both applications can chat between them and need to notify each other when data need to refresh from database (SQL).(when engineer send a message to agent or vise versa)

i have some difficulties using sql dependency notification (fires multiple times, or under some circumstances e.g internet connection reconnect, or when datetime change, or under some other unknown cases which i still didn't understand) and thought good to ask if i need to move on tcp client server approach.

another issue i have is that
i need to implement multiple instance of different kind of notifications which make the code more complicated
e.g
1.notification for text message
2. notification when an agent add a price
3. notification when something else
4. and so on

and all these under the problems I faced about multiple event fires from notifications and therefore multiple refresh on UI for no reason

is it good practice or pattern to follow and change logic to tcp server client for such a kind of application? or should i stick to sql notifications and try solve all that above one way or another?

Are chat apps using tcp client server for their exchange messages in now days?

in my case if I use tcp for the beginning it will be used only to send a small text "refresh" to the appropriate device (mobile or desktop) to notify the user and refresh the data.

but still not sure if i need to move on this way for such application

any help and which directions to follow is much appreciated.

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    For this question:

    i have some difficulties using sql dependency notification (fires multiple times, or under some circumstances e.g internet connection reconnect, or when datetime change, or under some other unknown cases which i still didn't understand)

    When we check SqlCommand Execution with a SqlNotificationRequest,we will find

    When using SQL Server notification requests with SqlDependency, we create our own queue , and how you poll the SQL Server queue and interpret the message is specific to your application. The application is responsible for polling the queue and reacting based on the contents of the message.

    Then since there is a notification message queue, why notification will been fired multiple times in your case.

    Besides, BTW, the current popular WeChat uses HTTP short connection and TCP long connection, which login authentication and portrait identity information and log functions used HTTP, text messages, voice messages, video messages, picture messages these use TCP long connection. Maintain long connection state through heartbeat packets, for example 300S a heartbeat.

  • jezhjezh Member, Xamarin Team Xamurai

    @ST.7899 Have you resolved your question?

  • ST.7899ST.7899 USMember ✭✭
    edited December 4

    @jezh

    I'm still investigating.. not sure yet what way to follow.. currently i'm using sql dependecy and same time trying to understand the difference between SqlDependecy vs SqlNotificationRequest, and how to use SqlNotificationRequest

    I'm still not sure how SqlNotificationRequest will help me.

    just for reference i'm posting here the code how i start monitoring a table to my database ( sorry for image, when posting code the format was mess

Sign In or Register to comment.