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 module tanya.async.protocol;
20 
21 import tanya.async.transport;
22 import tanya.net.socket;
23 
24 /**
25  * Common protocol interface.
26  */
27 interface Protocol
28 {
29     /**
30      * Params:
31      *  data = Read data.
32      */
33     void received(in ubyte[] data) @nogc;
34 
35     /**
36      * Called when a connection is made.
37      *
38      * Params:
39      *  transport = Protocol transport.
40      */
41     void connected(DuplexTransport transport) @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     void disconnected(SocketException exception) @nogc;
51 }
52 
53 /**
54  * Interface for TCP.
55  */
56 interface TransmissionControlProtocol  : Protocol
57 {
58 }