Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Silverlight webservice

Silverlight webservice

Scheduled Pinned Locked Moved Web Development
questioncsharpwcfgame-devjson
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mikla521
    wrote on last edited by
    #1

    I have made a Silverlight application which use a WCF webservice. I works fine but there is a small problem. The background: I run a gameserver and the game saves a resultfile which is updated in an interval (can be set). I have a webpage with a Silverlight app. The SL app uses webservice to update some data on the client, with an automatic update every 20 seconds or so. Also works fine. The Webservice parse the file from the game and that's no problem. But I realize that if, let's say, 50 ppl go to the page and just watch the SL app update, the webservice parses the file 50 times every 20 seconds! Not good... Here is how I want it to go: The client calls the webservice and gets the already parsed file as data. And the parsing/reading the file will update in the background and store the data to be ready for transfer to the client. But how do I make my webservice parse the file without the client calling the service? I actually don't know how to pass this problem... not an webservice expert either :) Any tips and was I clear enough?

    J 1 Reply Last reply
    0
    • M mikla521

      I have made a Silverlight application which use a WCF webservice. I works fine but there is a small problem. The background: I run a gameserver and the game saves a resultfile which is updated in an interval (can be set). I have a webpage with a Silverlight app. The SL app uses webservice to update some data on the client, with an automatic update every 20 seconds or so. Also works fine. The Webservice parse the file from the game and that's no problem. But I realize that if, let's say, 50 ppl go to the page and just watch the SL app update, the webservice parses the file 50 times every 20 seconds! Not good... Here is how I want it to go: The client calls the webservice and gets the already parsed file as data. And the parsing/reading the file will update in the background and store the data to be ready for transfer to the client. But how do I make my webservice parse the file without the client calling the service? I actually don't know how to pass this problem... not an webservice expert either :) Any tips and was I clear enough?

      J Offline
      J Offline
      Jeremy Likness
      wrote on last edited by
      #2

      We have a similar issue where we have a large block of data that displays on a dashboard. It can be accessed by 1..N clients and involves some complex queries and therefore we don't want to be re-running it each time the request is made. The solution is to cache on the server side. There are several ways to tackle this. I would start by abstracting your service with an interface (should be doing this already) and then having the interface also receive a cache interface, ICache. You can make it simple, for example, perhaps you construct it with a factory like this: ICache cache = CacheFactory.RetrieveCache(TimeSpan lifespan); This gives you flexibility for how long it is cached. Then, you might use the ASP.NET Web Cache - take a look here for some exhaustive examples/solutions: Exploring Caching in ASP.NET[^] Another option is to use the Singleton pattern and create a static class with a "lastcached" date and the parsed file. Basically, you expose a method "getparsedfile" and the method checks the lastcached. If it was cached less than you interval, it will simply return the cached object, otherwise it locks the object, updates the date and then re-parses the file. Hope that makes sense!

      Jeremy Likness Latest Article: Hierarchal Data Templates in Silverlight Blog: http://csharperimage.jeremylikness.com/

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups