Best practice for handling a large WCF service

I am working on a network of 4 players in WPF and learning WCF in the process. So far, to handle network communication, I have been following the advice of the game YeahTrivia in the game Coding4Fun : I use dualHttpBinding, and use the interface CallbackContractto send messages to clients. It works very well.

However, my service is becoming very large. It has methods / callbacks for processing the game itself, as well as a chat system, registration / registration process, matchmaking, growth / player information, etc. Both the server and the client become difficult to maintain, because everything is connected with a single interface. For example, on the client, I have to redirect callbacks to the game page, to the lobby page, etc., and I find it very tedious. I would rather be able to handle game callbacks on the game page, chat callbacks in the chat window, etc.

So what's the best way to handle this? I thought a lot about many things, but I'm not sure what is best: splitting a service into several, having several “endpoints” on my service, or other tricks for implementing the service, where is it necessary?

thanks

+3
source share
2 answers

You should have several components, each of which should be limited to one responsibility - not necessarily by one method, but by processing the state for one of the objects with which you are dealing. When you have everything in one service, your service is incredibly connected with itself. Optimally, each component should be as independent as possible.

I would say, start by dividing it where it makes sense, and everything should be MUCH more manageable.

+4
source

I would support Terry's answer - you should definitely split your large interface into several smaller ones.

, , / , - , , , , " " , .

, (, Silverlight - ), / .

+1

Source: https://habr.com/ru/post/1711190/


All Articles