Skip to main content
GameDev.net gamedev.net
🔒 Locked

What pattern is this?

Started by tstrimp Mar 29, 2007 at 11:22 AM 1 replies 1.3k views
Original Post
tstrimp
tstrimp
I've got an HttpListener running in a C# project. Whenever a request comes in I parse the RawUrl to get the path (/path/to/something.file) and pull out the first part which I use to determine the type of request coming in. Some examples of request I'll have to deal with...
/web/requestinfo?variable=123
/xmlrpc/
/soap/
etc...
Now I've got a RequestHandlerRegistry that you can register different types of handlers and replace existing handlers either in C# or via the scripting language I'm using. The RequestParser gets the appropriate Handler instance from the RequestHandlerRegistry based on the type string it obtained from above. Then is just passes the Handler the request and it's then up to the Handler to deal with it. This will allow me to add completely new handler types through the scripting system alone. This seems similar to the Factory pattern but the RequestHandlerRegistry doesn't create anything, just passes out instances that are registered with it. I'm mainly hoping to find common pitfalls associated with this type of design before I start heavily working on the actual Handlers themselves. Thanks! Tim
mrbastard
mrbastard
Sounds kind of like a mediator, whose purpose in this case is to implement a chain of responsibility.

Sort of [smile]
[size="1"]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.