MaClientServer--which method to modify to handle objects?
Chris Muller
afunkyobject at yahoo.com
Mon Jun 7 17:00:37 UTC 2004
> If I don't make a mistake, the default socket handler of the ma server is to
> send back an incoming request right back to client.
There is no default behavior, you must specify the "processBlock" when you
create your MaTcpRequestServer:
myRequestServer protocol: { MyClass1. MyClass2. }.
myRequestServer
processOn: 12345
do: [ : someRequestObject | KwiyiRequestProcessor getResponseFor:
someRequestObject ]
> 1) Should I modify the method "processRequest: socketAndRequestAssociation"
> if I run it at socket layer.
No. As you can see, that is a private method. It is not intended for you to
use or modify.
> 2) Which method should I modify to process the request or response as an
> object if I run it at object layer?
You do not modify any methods. You just write your own methods in your own
class to create the MaTcpRequestServer and tell it to processOn:do:. For
example, let's say you create your server called KwiyiRequestProcessor. In
there, you give it a 'server' instance variable which you initialize with the
appropriate protocol (see MaTcpRequestServer class>>protocol:).
KwiyiRequestProcessor>>initialize
server := MaTcpRequestServer protcol: { MyClass1. MyClass2. }.
You need a method to handle requests:
KwiyiRequestProcessor>>getResponseFor: someRequestObject
... take someRequestObject and process however you want ...
^ the answer response
To get it started, implement a method that tells the server to processOn:do:.
KwiyiRequestProcessor>>startUp
server
processOn: 12345
do: [ : request | self getResponseFor: request ]
Don't forget your shutdown method:
KwiyiRequestProcessor>>shutdown
server shutdown
Does that help?
- Chris
More information about the Squeak-dev
mailing list
|