Page 1 of 1

The TcpIpConnection Class

Posted: Fri Aug 07, 2009 11:58 am
by ConvertFromOldNGs
by JADE Kid - Ray Hidayat >> Fri, 5 Jan 2001 22:10:32 GMT

I have a server class. It has a method called connect. That connects to that server. But once it connects, I need to keep this TcpIpConnection open, and I need to store a reference to it.

But server is persistent. I have a list of servers which I can connect to. That is why it is persistent. So that means, no persistent to transient references.

What do I do?

--
Ray Hidayat
JADE Kid - 2000
www.jadekids.com

Re: The TcpIpConnection Class

Posted: Fri Aug 07, 2009 11:58 am
by ConvertFromOldNGs
by John Eyers >> Sun, 7 Jan 2001 20:44:36 GMT

TCP connections are transient by nature - they only exist while the Jade program is running whereas persistent objects exist between Jade program executions, so there is no need to store persistent references to connections.

However I can see that you would need such references while the connections are in use, and one way to do this is via a new transient object which holds references to both the server and the connection. Use this in place of the server object while processing the connections. When the connection is closed, this object can be deleted.

Re: The TcpIpConnection Class

Posted: Fri Aug 07, 2009 11:58 am
by ConvertFromOldNGs
by Wilfred Verkley >> Mon, 8 Jan 2001 0:21:29 GMT

IMHO, you are putting behaviour in the wong place. Treat the "Server" class simply as information about the servers you can connect to. Make another transient object ie "ServerConnection" which holds the behaviour of actually connecting to that server. This would hold the TCPIPConnection class as well, and it would only exist for the lifetime of that connection.

Wilfred.

Re: The TcpIpConnection Class

Posted: Fri Aug 07, 2009 11:58 am
by ConvertFromOldNGs
by JADE Kid - Ray Hidayat >> Mon, 8 Jan 2001 4:39:33 GMT

Okay. This sounds like a good idea.

--
Ray Hidayat
JADE Kid - 2000
www.jadekids.com

Re: The TcpIpConnection Class

Posted: Fri Aug 07, 2009 11:58 am
by ConvertFromOldNGs
by Robert Barr >> Sun, 14 Jan 2001 21:36:29 GMT

JADE provides "app" as a singleton transient reference that you can always rely on being available. You can use this to store references, both transient (runtime) and persistent reference information, e.g.

app.myTcpConnection (reference to transient TcpConnection class) app.serverInformation (reference to persistent Server class)

I'd suggest your connect() method should be defined on the TcpConnection class, or on app. The method can either refer directly to app.serverInformation, or the relevant server connection parameters can be passed as a parameter to the method.