Article Preview
Buy Now
COLUMN
Designing a Server Class
The Facade and Mediator Patterns In Action
Issue: 4.6 (July/August 2006)
Author: Charles Yeomans
Author Bio: Charles is the author of "I Declare: Calling External Functions in REALbasic", available online at
Article Description: No description available.
Article Length (in bytes): 6,616
Starting Page Number: 37
Article Number: 4614
Resource File(s):
4614.zip Updated: 2006-07-16 09:38:01
Related Web Link(s):
http://www.declareSub.com/
Excerpt of article text...
I needed to implement a server as part of an application. In the initial version, I dropped a ServerSocket and an EasyTCPSocket onto a window, made the EasyTCPSocket into a control array, and implemented the events. I then wanted to replace the window with a Server class. But only in a Window can you implement events of other objects. I wanted to keep this capability in order to avoid a tangled mess of event-handling, but I didn't want to misuse a window to do so. Also, I wanted Server to be a singleton object. Here's how I did it.
Let's begin with a subclass DelegatingServerSocket of ServerSocket. To it, we add a public property EventHandler as ServerSocketEventHandler. Because we do not know who will want to handle ServerSocket events, we make ServerSocketEventHandler a class interface. Give it the following methods.
...End of Excerpt. Please purchase the magazine to read the full article.