1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4 5 /**
6 * This module contains protocol which handle data in asynchronous
7 * applications.
8 *
9 * When an event from the network arrives, a protocol method gets
10 * called and can respond to the event.
11 *
12 * Copyright: Eugene Wissner 2016-2020.
13 * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
14 * Mozilla Public License, v. 2.0).
15 * Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
16 * Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/async/protocol.d,
17 * tanya/async/protocol.d)
18 */19 moduletanya.async.protocol;
20 21 importtanya.async.transport;
22 importtanya.net.socket;
23 24 /**
25 * Common protocol interface.
26 */27 interfaceProtocol28 {
29 /**
30 * Params:
31 * data = Read data.
32 */33 voidreceived(inubyte[] data) @nogc;
34 35 /**
36 * Called when a connection is made.
37 *
38 * Params:
39 * transport = Protocol transport.
40 */41 voidconnected(DuplexTransporttransport) @nogc;
42 43 /**
44 * Called when a connection is lost.
45 *
46 * Params:
47 * exception = $(D_PSYMBOL Exception) if an error caused
48 * the disconnect, $(D_KEYWORD null) otherwise.
49 */50 voiddisconnected(SocketExceptionexception) @nogc;
51 }
52 53 /**
54 * Interface for TCP.
55 */56 interfaceTransmissionControlProtocol : Protocol57 {
58 }