Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 20 in printed book and digital formats -- plus a one-year subscription (beginning with 21.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Recent issues

Article Preview


Buy Now

Issue 4.6

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 http://www.declareSub.com/
Article Description: No description available.
Article Length (in bytes): 6,616
Starting Page Number: 37
Article Number: 4614
Resource File(s):

Download Icon 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.