Re: OT Notifier
Re: OT Notifier
- Subject: Re: OT Notifier
- From: Anders Pytte <email@hidden>
- Date: Wed, 20 Feb 2002 21:19:13 -0500
The context passed to EventHandler is whatever you pass to
OTAsyncOpenEndpointInContext for contextPtr, not what you pass for
clientContext. Since you are passing 0 (i.e. NULL) for that parameter,
OT is passing NULL to EventHandler.
The value passed in cookie will depend on the event code. When the event
code is T_OPENCOMPLETE, in response to an OpenEndpoint request, cookie
will contain a pointer to the new endpoint. This will be of the type
EndpointRef. (I cannot even find EPInfo in recent release of the
universal headers - is this an old OpenTransport construct?).
If you want to save the endpoint passed in with the T_OPENCOMPLETE
event, you must pass a pointer to your own data structure in the
contextPtr parameter of OTAsyncOpenEndpointInContext, and save the
endpoint reference in that structure. For example:
struct EndpointContext {
EndpointRef endpointRef;
// etc.
};
EndpointContext* contextPtr = new EndpointContext; // make sure
this storage lasts as long as the endpoint
err = OTAsyncOpenEndpointInContext
( OTCreateConfiguration(kTCPName), 0, &info, theHandler, contextPtr,
NULL);
static pascal void EventHandler( void* context, OTEventCode event,
OTResult result, void* cookie ) {
EndpointContext* contextPtr = (EndpointContext*) context; //
reinterpret_cast would be more proper
contextPtr-> endpointRef = (EndpointRef) cookie;
}
Then you would have access to the EndpointRef when EventHandler was
called later to handle other events.
Anders.
On Wednesday, February 20, 2002, at 06:22 PM, Michael Paluszek wrote:
I'm still trying to work through the notifier problem. Given a notifier
of
the form
static pascal void EventHandler( void* context, OTEventCode event,
OTResult
result, void* cookie )
{
TCall mycall;
InetAddress caddr;
TEndpoint *ep;
OSStatus err;
int kSc;
// Endpoint information
EPInfo* epi = (EPInfo*) context;
The asynchronous handler is installed using:
OTNotifyUPP theHandler = NewOTNotifyUPP( EventHandler );
err = OTAsyncOpenEndpointInContext
( OTCreateConfiguration(kTCPName), 0,
&info, theHandler, 0, NULL );
On MacOS 9.x cookie in EventHandler contains the endpoint. On OS X it
is a
null pointer. I added the context input but noticed on OS 9.x that all
I get
is a null pointer for the context. This event handler seems to follow
the
documentation and the many pieces of OT sample code (including
OTVirtualServer.)
Basically, I have several controllers communicating with the simulation
(which is simulating several processes). I need to know which endpoint
is
incoming so that I can send the data to the correct process.
Does anyone have a suggestion of what I might be doing incorrectly?
Thanks!
Sincerely,
Mike
-------
Michael A. Paluszek
Princeton Satellite Systems, Inc.
33 Witherspoon Street
Princeton, New Jersey 08542-3207
USA
Telephone: (609) 279-9606
Fax: (609) 279-9607
URL: http://www.psatellite.com
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.
References: | |
| >OT Notifier (From: Michael Paluszek <email@hidden>) |