1 module gfm.enet.event; 2 3 import derelict.enet.enet; 4 5 import gfm.enet.enet, 6 gfm.enet.packet, 7 gfm.enet.peer; 8 9 final class Event 10 { 11 private 12 { 13 ENetEvent *_handle; 14 Peer _peer; 15 Packet _packet; 16 } 17 18 public 19 { 20 this(ENet enet, ENetEvent *handle) 21 { 22 _handle = handle; 23 _peer = new Peer(enet, _handle.peer); 24 if(_handle.type == ENET_EVENT_TYPE_RECEIVE) 25 _packet = new Packet(enet, _handle.packet); 26 else 27 _packet = null; 28 } 29 30 /// Trivial getters for _ENetEvent struct. 31 ENetEventType type() pure const nothrow 32 { 33 return _handle.type; 34 } 35 36 Peer peer() pure nothrow 37 { 38 return _peer; 39 } 40 41 ubyte channelID() pure const nothrow 42 { 43 return _handle.channelID; 44 } 45 46 uint data() pure const nothrow 47 { 48 return _handle.data; 49 } 50 51 Packet packet() pure nothrow 52 { 53 return _packet; 54 } 55 } 56 }