tags:

views:

102

answers:

5

Where would I start with firing an event over a network? In my case, when I change a database record, I want to inform any other user on the network running the same application that it has changed.

Edit:

It's nothing clever, don't get excited. I'm writing a document management system and when a document is changed in any way (deleted, checked out, up issued, etc), I want to "tell" everyone something's changed. I was going to use a FileSystemWatcher to watch a folder on the server, sign each instance up to it's Deleted event and just create and delete a file in the watched directory, but that's just dirty isn't it? As you can tell, I'm not a professional programmer :)

A: 

Each instance of your client application could be listening to a socket of messages.

When your server application changes the database record (on behalf of a client, or for any other reason), it also inserts a "something changed" message in the queue of messages for each client.

The server application could either immediately send the message to the client application - or the client application could poll.

Matt Cruikshank
A: 

Have clients register themselves with a central app. Whenever the client updates the record it can notify the central app which then broadcast it to the registered clients.

Decide for yourself on transport mechanism, but you may want to consider sockets.

CrashCodes
+2  A: 

What kind of notification timeframe are you after? I would personally have the client machines poll the server for updates - e.g. "My most recent update was on 17/02/2009 11:56:00 - what's changed since then?" - by implementing a webservice or simple socket-based server on the actual server.

Otherwise, if it is a distributed app, your "simplest" bet would be a UDP broadcast - assuming they are on the same subnet and not separated by 20 degrees of routers.

Can you tell us a bit more about your situation?

Fritz H
A: 

WCF can make this happen for you. I have a server that sends and alarm to all the clients when something happens.

Khadaji
A: 

How do you keep track of file edits?

I am assuming you are using a database (If not, now's a good time to set one up) - in which case, I would recommend writing an ASP.NET webservice (.asmx extension - Visual Studio can make them really easy) to communicate with this database and tell the client if any files have been modified since the last time it checked.

Try to create a webservice for the server in Visual Studio to see how it's done. To consume ("use") a webservice on the client machine, open up your VS project, right click on the "References" node under the project and select "Add Web Reference".

The client would need to poll the webservice, though, as it's a one-way call-response type mechanism.

The advantage of this is that you needn't worry about network shares and such things. The disadvantage, however, is that you need an ASP.NET-capable webserver and database engine, unless they are already present.

Fritz H