Network API
#77
I'd like to change the connection-accepting code, so that the link callbacks that are given to the new link are received from the cNetwork::cListenCallbacks::OnAccepted() callback, rather than given to the cNetwork::Listen() function. Without this, it would become too cumbersome to actually use the cNetwork API in the server (binding the connections to clients would require several helper classes).

Unfortunately this means that the OnAccepted() callback will not be able to receive a cTCPLink instance, because the instance needs those callbacks to be created. If this proves to be a problem, we can add a second callback, OnLinkCreated() that will be called right after the link is created for the new connection.
Or maybe keep the OnAccept() callback as is, but add an OnIncomingConnection() callback that is called first to obtain the link callbacks:
class cNetwork
{
	...
	class cListenCallbacks
	{
	public:
		/** Called when the TCP server created with Listen() receives a new incoming connection.
		Returns the link callbacks that the server should use for the newly created link.
		If a nullptr is returned, the connection is dropped immediately;
		otherwise a new cTCPLink instance is created and OnAccepted() is called. */
		virtual cTCPLink::cCallbacksPtr OnIncomingConnection(const AString & a_RemoteIPAddress) = 0;

		/** Called when the TCP server created with Listen() creates a new link for an incoming connection.
		Provides the newly created Link that can be used for communication.
		Called right after a successful OnIncomingConnection(). */
		virtual void OnAccepted(cTCPLink & a_Link) = 0;

		...
Reply
Thanks given by:


Messages In This Thread
Network API - by xoft - 12-31-2014, 04:49 AM
RE: Network API - by NiLSPACE - 12-31-2014, 04:59 AM
RE: Network API - by xoft - 12-31-2014, 05:28 AM
RE: Network API - by wolfmitchell - 01-01-2015, 01:01 PM
RE: Network API - by NiLSPACE - 01-01-2015, 10:11 PM
RE: Network API - by xoft - 01-02-2015, 06:58 AM
RE: Network API - by sphinxc0re - 01-02-2015, 09:26 AM
RE: Network API - by xoft - 01-02-2015, 05:23 PM
RE: Network API - by sphinxc0re - 01-02-2015, 08:45 PM
RE: Network API - by jan64 - 01-05-2015, 01:59 AM
RE: Network API - by wolfmitchell - 01-05-2015, 06:27 AM
RE: Network API - by jan64 - 01-05-2015, 07:22 AM
RE: Network API - by wolfmitchell - 01-05-2015, 08:22 AM
RE: Network API - by xoft - 01-05-2015, 07:46 AM
RE: Network API - by worktycho - 01-05-2015, 09:37 PM
RE: Network API - by xoft - 01-06-2015, 02:02 AM
RE: Network API - by worktycho - 01-06-2015, 02:07 AM
RE: Network API - by worktycho - 01-06-2015, 04:55 AM
RE: Network API - by xoft - 01-06-2015, 06:11 AM
RE: Network API - by xoft - 01-06-2015, 06:46 AM
RE: Network API - by worktycho - 01-06-2015, 06:58 AM
RE: Network API - by xoft - 01-06-2015, 07:18 AM
RE: Network API - by jan64 - 01-06-2015, 08:29 AM
RE: Network API - by worktycho - 01-06-2015, 09:12 AM
RE: Network API - by jan64 - 01-06-2015, 09:14 AM
RE: Network API - by worktycho - 01-06-2015, 09:35 AM
RE: Network API - by jan64 - 01-06-2015, 09:43 AM
RE: Network API - by worktycho - 01-06-2015, 09:53 AM
RE: Network API - by jan64 - 01-06-2015, 10:01 AM
RE: Network API - by worktycho - 01-06-2015, 10:08 AM
RE: Network API - by xoft - 01-06-2015, 06:17 PM
RE: Network API - by jan64 - 01-06-2015, 09:49 PM
RE: Network API - by xoft - 01-09-2015, 07:27 PM
RE: Network API - by NiLSPACE - 01-09-2015, 07:43 PM
RE: Network API - by xoft - 01-09-2015, 08:11 PM
RE: Network API - by xoft - 01-09-2015, 08:36 PM
RE: Network API - by NiLSPACE - 01-09-2015, 09:23 PM
RE: Network API - by jan64 - 01-11-2015, 02:04 AM
RE: Network API - by xoft - 01-12-2015, 07:21 PM
RE: Network API - by NiLSPACE - 01-12-2015, 09:07 PM
RE: Network API - by xoft - 01-12-2015, 09:29 PM
RE: Network API - by NiLSPACE - 01-12-2015, 10:38 PM
RE: Network API - by xoft - 01-12-2015, 10:46 PM
RE: Network API - by NiLSPACE - 01-12-2015, 10:56 PM
RE: Network API - by xoft - 01-12-2015, 11:30 PM
RE: Network API - by NiLSPACE - 01-13-2015, 12:28 AM
RE: Network API - by xoft - 01-13-2015, 12:52 AM
RE: Network API - by NiLSPACE - 01-13-2015, 12:59 AM
RE: Network API - by xoft - 01-13-2015, 01:20 AM
RE: Network API - by NiLSPACE - 01-13-2015, 02:31 AM
RE: Network API - by xoft - 01-13-2015, 05:09 PM
RE: Network API - by xoft - 01-14-2015, 03:06 AM
RE: Network API - by NiLSPACE - 01-14-2015, 04:15 AM
RE: Network API - by worktycho - 01-14-2015, 04:22 AM
RE: Network API - by xoft - 01-14-2015, 05:25 PM
RE: Network API - by worktycho - 01-14-2015, 09:47 PM
RE: Network API - by xoft - 01-14-2015, 11:12 PM
RE: Network API - by xoft - 01-14-2015, 11:18 PM
RE: Network API - by worktycho - 01-14-2015, 11:45 PM
RE: Network API - by NiLSPACE - 01-16-2015, 03:02 AM
RE: Network API - by xoft - 01-16-2015, 06:12 AM
RE: Network API - by NiLSPACE - 01-16-2015, 09:34 PM
RE: Network API - by worktycho - 01-16-2015, 10:02 PM
RE: Network API - by NiLSPACE - 01-16-2015, 10:26 PM
RE: Network API - by xoft - 01-17-2015, 12:09 AM
RE: Network API - by NiLSPACE - 01-17-2015, 12:16 AM
RE: Network API - by NiLSPACE - 01-17-2015, 12:47 AM
RE: Network API - by xoft - 01-17-2015, 01:09 AM
RE: Network API - by xoft - 01-17-2015, 01:13 AM
RE: Network API - by NiLSPACE - 01-17-2015, 01:19 AM
RE: Network API - by xoft - 01-17-2015, 09:55 AM
RE: Network API - by NiLSPACE - 01-17-2015, 10:08 AM
RE: Network API - by xoft - 01-18-2015, 08:48 AM
RE: Network API - by NiLSPACE - 01-18-2015, 09:18 AM
RE: Network API - by xoft - 01-19-2015, 07:45 AM
RE: Network API - by worktycho - 01-19-2015, 08:21 AM
RE: Network API - by xoft - 01-21-2015, 01:16 AM
RE: Network API - by xoft - 01-21-2015, 08:00 PM
RE: Network API - by NiLSPACE - 01-21-2015, 08:17 PM
RE: Network API - by NiLSPACE - 01-23-2015, 01:41 AM
RE: Network API - by xoft - 01-23-2015, 02:30 AM
RE: Network API - by xoft - 01-24-2015, 05:08 AM
RE: Network API - by worktycho - 01-25-2015, 12:00 AM
RE: Network API - by xoft - 01-25-2015, 12:09 AM
RE: Network API - by worktycho - 01-25-2015, 12:24 AM
RE: Network API - by xoft - 01-25-2015, 12:56 AM
RE: Network API - by worktycho - 01-25-2015, 01:00 AM
RE: Network API - by xoft - 01-25-2015, 01:02 AM
RE: Network API - by xoft - 01-25-2015, 06:04 AM
RE: Network API - by xoft - 01-26-2015, 11:53 PM
RE: Network API - by NiLSPACE - 01-27-2015, 05:47 AM
RE: Network API - by xoft - 01-27-2015, 10:59 PM
RE: Network API - by NiLSPACE - 01-28-2015, 12:09 AM
RE: Network API - by xoft - 01-28-2015, 12:21 AM
RE: Network API - by xoft - 01-28-2015, 11:29 PM
RE: Network API - by NiLSPACE - 01-29-2015, 12:04 AM
RE: Network API - by xoft - 01-29-2015, 12:19 AM
RE: Network API - by wudles - 01-29-2015, 07:52 AM
RE: Network API - by xoft - 01-30-2015, 11:04 AM
RE: Network API - by xoft - 01-31-2015, 08:11 AM
RE: Network API - by Raekye - 02-05-2015, 05:45 AM
RE: Network API - by xoft - 02-05-2015, 05:50 AM
RE: Network API - by Raekye - 02-05-2015, 06:36 AM
RE: Network API - by xoft - 02-08-2015, 03:05 AM
RE: Network API - by Howaner - 02-08-2015, 03:52 AM
RE: Network API - by worktycho - 02-08-2015, 04:17 AM
RE: Network API - by Howaner - 02-08-2015, 05:43 AM
RE: Network API - by xoft - 02-13-2015, 05:07 AM
RE: Network API - by NiLSPACE - 02-13-2015, 07:00 AM
RE: Network API - by xoft - 02-13-2015, 07:04 AM
RE: Network API - by NiLSPACE - 02-14-2015, 02:07 AM
RE: Network API - by xoft - 02-14-2015, 02:21 AM
RE: Network API - by NiLSPACE - 02-14-2015, 02:29 AM
RE: Network API - by xoft - 02-14-2015, 08:23 AM
RE: Network API - by NiLSPACE - 02-15-2015, 12:17 AM
RE: Network API - by NiLSPACE - 02-15-2015, 01:45 AM
RE: Network API - by NiLSPACE - 02-15-2015, 11:40 PM
RE: Network API - by xoft - 02-15-2015, 11:54 PM
RE: Network API - by xoft - 02-16-2015, 12:12 AM
RE: Network API - by jan64 - 02-16-2015, 01:45 AM
RE: Network API - by NiLSPACE - 02-16-2015, 02:26 AM
RE: Network API - by NiLSPACE - 02-16-2015, 06:34 AM
RE: Network API - by bearbin - 02-16-2015, 06:35 AM
RE: Network API - by jan64 - 02-16-2015, 07:38 AM
RE: Network API - by xoft - 02-16-2015, 07:57 AM
RE: Network API - by sphinxc0re - 02-16-2015, 08:50 AM
RE: Network API - by NiLSPACE - 02-16-2015, 05:35 PM
RE: Network API - by xoft - 02-16-2015, 06:13 PM
RE: Network API - by xoft - 02-19-2015, 07:23 AM
RE: Network API - by xoft - 02-20-2015, 08:37 AM
RE: Network API - by sphinxc0re - 02-20-2015, 09:23 AM
RE: Network API - by NiLSPACE - 02-20-2015, 05:31 PM
RE: Network API - by Raekye - 02-21-2015, 06:24 AM
RE: Network API - by NiLSPACE - 02-28-2015, 05:13 AM
RE: Network API - by xoft - 02-28-2015, 05:33 AM
RE: Network API - by NiLSPACE - 02-28-2015, 06:54 AM
RE: Network API - by xoft - 02-28-2015, 07:07 AM
RE: Network API - by NiLSPACE - 05-11-2015, 02:32 AM
RE: Network API - by NiLSPACE - 10-01-2015, 11:44 PM
RE: Network API - by xoft - 10-01-2015, 11:59 PM
RE: Network API - by NiLSPACE - 10-02-2015, 12:11 AM
RE: Network API - by xoft - 10-03-2015, 11:18 PM
RE: Network API - by worktycho - 10-03-2015, 11:49 PM
RE: Network API - by NiLSPACE - 11-24-2015, 07:59 PM



Users browsing this thread: 14 Guest(s)