1 module doap.client.messaging.core; 2 3 import doap.client.client : CoapClient; 4 import std.socket : Address; 5 import doap.protocol.packet : CoapPacket; 6 7 public abstract class CoapMessagingLayer 8 { 9 /** 10 * The client 11 */ 12 private CoapClient client; 13 14 /** 15 * Constructs a new messaging layer instance 16 * associated with the provided client 17 * 18 * Params: 19 * client = the client 20 */ 21 this(CoapClient client) 22 { 23 this.client = client; 24 } 25 26 /** 27 * Retrieves the client associated with 28 * this messaging layer 29 * 30 * Returns: the `CoapClient` 31 */ 32 public final CoapClient getClient() 33 { 34 return this.client; 35 } 36 37 /** 38 * Retrieves the CoAP endpoint the client is 39 * connected to 40 * 41 * Returns: the endpoint address 42 */ 43 protected final Address getEndpointAddress() // Final in Interface 44 { 45 return this.client.address; 46 } 47 48 /** 49 * Starts the messaging layer 50 */ 51 public abstract void begin(); 52 53 /** 54 * Transmit the provided packet 55 * 56 * Params: 57 * packet = the `CoapPacket` 58 * to transmit 59 */ 60 public abstract void send(CoapPacket packet); 61 62 /** 63 * Stops the messaging layer 64 */ 65 public abstract void close(); 66 }