473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Web service and filtering list

17
Hi. I have two questions.

#1. I'm thinking of creating a web service which contain a list object which contain a number of entrys of the own-defined class Match, which will have the variables:
MapID (int)
Number of players (int)
SkillLevel (enum)
ServerIsOn (bool)
In a Windows application you can either choose to search for matches or create a match which will be searchable to others. If you choose to create a match, a new instance of the Match object is created with the settings you specify and then added to the list on the web service.If you choose to search for matches instead, you retrieve the list and filter it (see question #2), and retrieve the list from the server again every 10 seconds or when the user self press an Update-button. Now, to my question:
How do I create a web service for this?
Can you show me some examples? I'd be grateful if you also showed me some example methods for the application as well.

#2. When you've retrieved the list from the server, you want to filter it to only show the results you want to see. How do you do that? Like this?
Expand|Select|Wrap|Line Numbers
  1. private void filter()
  2. {
  3.     foreach (Match m in retrievedList)
  4.     {
  5.         if (m.MapID == map && m.NumberOfPlayers == nrOfPlayers && m.SkillLevel == skill && m.ServerIsOn == serverOn)
  6.         {
  7.             filteredList.Add(m);
  8.         }
  9.     }
  10.  
  11.     // methods for displaying the filtered list in the application
  12.     ...
  13. }
Thanks in advance.

Oh, and sorry for my English and for a messy post :P
Sep 12 '09 #1
3 2720
cloud255
427 Expert 256MB
Hi,

I would suggest doing the filtering on the server, this will save having to transfer a full list to the client every X seconds.

I would override the Filter method to cater for the possible combinations of settings; a quick example:

Expand|Select|Wrap|Line Numbers
  1. Public List<Match> Filter()
  2. {
  3.     //return all available matches
  4. }
  5.  
  6. Public List<Match> Filter(int MapID)
  7. {
  8.     //return all matches for a specific map regardless of other settings
  9. }
  10.  
  11. Public List<Match> Filter(int MapID, int NumPlayers)
  12. {
  13.     //return all matches for a specific map and number of players
  14. }
Using Linq for your actual filtering will probably be faster than using foreach loops, when creating an application like this you need to pay alot of attention to optimization.

As for the client updating every X seconds (10 might be a bit short) the client should run a thread with a timer that requests the server to perform a new filter operation, you can interrupt this thread to send a manual refresh request. Take note to make communication asynchronous as if the server is unavailable your client will forever try to get data from the server.
Sep 13 '09 #2
Saser
17
Thanks for your answer.

If I'd override the Filter() method, I'd need to create an override for every possible combination of settings, for example I'd need to create one method for players and map, another for players and skill, another for map and skill and so forth...
Kinda nooby question, but is it really necessary to do this? Can't I just create one Filter() method which includes all parameters, and if I want to search for e.g. matches with 3 players, skilllevel any and de_inferno as map and don't care if server is on or off, can't I just call the filter method with this parameters (ServerIsOn as an enum instead of bool):
Expand|Select|Wrap|Line Numbers
  1. List<Match> matchList = WebService.Filter(1, 3, Skill.Any, ServerStatus.Any);
I'm not really into threading and I don't know anything about Linq, can you link me some tutorial or show examples of what you mean?
Thanks in advance.
Sep 13 '09 #3
cloud255
427 Expert 256MB
@Saser
No you can use just one function, the function might just become a bit big and hard to maintain IMHO.

@Saser
Linq
Thread Class
Threading tips

Hope this helps
Sep 13 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Alex Ayzin | last post by:
Hi, I have a problem that might be easy to solve(possibly, I've just overlooked an easy solution). Here we go: I have a dataset with 2 datatables in it. Now, I need to do the following: if...
13
by: kevinold | last post by:
Hello everyone, I have a list of about 1600 employees that I'd like to have displayed in a form. I'd like to make the "search" for the user as easy as possible. I ran across this:...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
5
by: sensible | last post by:
Can I solve this problem using Access? If so, will some give this newbie a simple step by step on how to go about it, please....all the way from File/New. In Excel I am using...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
2
by: JUAN ERNESTO FLORES BELTRAN | last post by:
Hi you all, I am developping a python application which connects to a database (postresql) and displays the query results on a treeview. In adittion to displaying the info i do need to implement...
2
by: Anders K. Olsen | last post by:
Hello group I would like some advice on how to model my webservices. Our application is made up of a number of independent modules that handle different parts of the application logic. It is a...
3
by: Harry Haller | last post by:
Hello, I want to implement a generic list which will be used to display 7 columns in a GridView. One should be able to sort, filter and page each of the 7 columns. Ideally the filter should be...
3
by: Krish | last post by:
Hi All, I have a component that reads a file and returns the data as a an array of objects. Now I want to add the capability of filtering on this. This means if an array of objects is returned...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.