1 module cheetah.socketeventargs; 2 3 import cheetah.socketserver; 4 import cheetah.socketclient; 5 6 /// Wrapper for socket event arguments 7 class SocketEventArgs(T) { 8 private: 9 /// The server. 10 SocketServer!T _server; 11 12 /// The client. 13 SocketClient!T _client; 14 15 /// The error. 16 Exception _error; 17 18 public: 19 /** 20 * Creates a new socket event argument wrapper. 21 * Params: 22 * server = The server. 23 * client = The client. 24 * error = (optional) The error. 25 */ 26 this(SocketServer!T server, SocketClient!T client, Exception error = null) { 27 _server = server; 28 _client = client; 29 _error = error; 30 } 31 32 @property { 33 /// Gets the server. 34 auto server() { return _server; } 35 36 /// Gets the client. 37 auto client() { return _client; } 38 39 /// Gets the error. 40 auto error() { return _error; } 41 42 /// Gets the amount of available bytes for receive. 43 size_t availableReceiveAmount() @trusted { return _client.availableReceiveAmount; } 44 45 /// Gets the current received amount of bytes. 46 size_t currentReceiveAmount() pure const @safe { return _client.currentReceiveAmount; } 47 48 /// Gets the current buffer. 49 auto buffer() { return _client.buffer; } 50 } 51 52 /** 53 * Resets the current receive state. 54 * Params: 55 * cachedAmount = (optional) An amount of cached bytes. 56 */ 57 void resetReceive(size_t cachedAmount = 0) { 58 _client.resetReceive(cachedAmount); 59 } 60 }