0

I have the following scenario.

As my next project, i try to implement a chat application. I found out about Sql Table Dependency and i did a c# client witch use SqlTableDependecy and it`s ok. But now i want to come with WCF service in the middle so sql connection will be secured.

The problem is, how do i receive data from SQL in WCF service and from there to send it to my C# client app instant. I don`t want to use Timers in my C# client app.

  1. In sql i insert a new row in table.
  2. This change will be received by WCF service ( hosted on IIS )
  3. How do i send that information from WCF in C# client app imedialty. How do i consume the WCF service.

I accept any guidance or tips for this project. Ty

Zerfad
  • 1
  • I would go with a REST API hosted on IIS. Client needs to access data, asks the API, API gets it from SQL and returns it. – stersym Jan 13 '22 at 10:20
  • I tried this. The problem is "when the client decide to ask the rest api" because the c# client has control over the sql table. I`m thinking at this scenario. 1. User 1 will input a message and hit enter. 2. The message will be stored in Sql Table 3. Now WCF service will receive the data from table with Sql table dependency method 4. How c# client app from User 2 know when to consume WCF Service ? -> this is my problem – Zerfad Jan 13 '22 at 10:27
  • You can take a look at [SQL Cache Dependency](https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/caching-support-for-wcf-web-http-services#sql-cache-dependency) and [How to: Create a Duplex Contract](https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-create-a-duplex-contract). – Lan Huang Jan 14 '22 at 08:14

1 Answers1

0

When i understood you correctly, what you need is messaging or a duplex contract.

Look at this simliar problem: WCF service send data to client

this.harry
  • 23
  • 7