All write functions share the same signature:
size_t write(const uint8_t *buf, size_t len);
So I'd define my function pointer like so:
typedef size_t (* writePtr) (const uint8_t *, size_t);
writePtr outputWriteChannel;
And call it like so:
WiFiClient testWifiClient;
// populate wifi client obviously
AsyncClient testAsyncClient;
// populate async client obviously
uint8_t buf[100];
strcpy(buf, "Hello World!");
outputWriteChannel = &Serial.write;
outputWriteChannel(buf, len); // Goes to Serial
outputWriteChannel = &testWifiClient.write;
outputWriteChannel(buf, len); // Goes to Synchronous TCP client
outputWriteChannel = &testAsyncClient.write;
outputWriteChannel(buf, len); // Goes to aSynchronous TCP client
That, however, failes at compile time. Does anybody know how I would do it correctly?