1 /* 2 * This file was automatically generated by sel-utils and 3 * released under the MIT License. 4 * 5 * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 * Repository: https://github.com/sel-project/sel-utils 7 * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/protocol/externalconsole1.xml 8 */ 9 module sul.protocol.externalconsole1.types; 10 11 import std.bitmanip : write, peek; 12 static import std.conv; 13 import std.system : Endian; 14 import std.typecons : Tuple; 15 import std.uuid : UUID; 16 17 import sul.utils.buffer; 18 import sul.utils.var; 19 20 static if(__traits(compiles, { import sul.metadata.externalconsole1; })) import sul.metadata.externalconsole1; 21 22 struct Game { 23 24 // type 25 public enum ubyte POCKET = 1; 26 public enum ubyte MINECRAFT = 2; 27 28 public enum string[] FIELDS = ["type", "protocols"]; 29 30 /** 31 * Variant of the game. 32 */ 33 public ubyte type; 34 35 /** 36 * List of protocols supported by the server for the indicated game. 37 */ 38 public uint[] protocols; 39 40 public pure nothrow @safe void encode(Buffer buffer) { 41 with(buffer) { 42 writeBigEndianUbyte(type); 43 writeBigEndianUshort(cast(ushort)protocols.length); foreach(cjd9bx;protocols){ writeBigEndianUint(cjd9bx); } 44 } 45 } 46 47 public pure nothrow @safe void decode(Buffer buffer) { 48 with(buffer) { 49 type=readBigEndianUbyte(); 50 protocols.length=readBigEndianUshort(); foreach(ref cjd9bx;protocols){ cjd9bx=readBigEndianUint(); } 51 } 52 } 53 54 public string toString() { 55 return "Game(type: " ~ std.conv.to!string(this.type) ~ ", protocols: " ~ std.conv.to!string(this.protocols) ~ ")"; 56 } 57 58 } 59 60 /** 61 * Resources usage of a node. 62 */ 63 struct NodeStats { 64 65 public enum string[] FIELDS = ["name", "tps", "ram", "cpu"]; 66 67 /** 68 * Name of the node. Should match one of the names given in [Welcome.Accepted.connectedNodes](#login_welcome_accepted_connected-nodes) 69 * or one added using the UpdateNodes packet. 70 * If the server isn't built on the hub-node layout the name is an empty string and 71 * the following values are for the whole server and not for a node. 72 */ 73 public string name; 74 75 /** 76 * Ticks per second of the node in range 0 to 20. If the value is less than 20, the 77 * server is lagging. 78 */ 79 public float tps; 80 81 /** 82 * RAM allocated by the node in bytes. 83 * If the value is 0 the node couldn't retrieve the amount of memory allocated by its 84 * process. 85 */ 86 public ulong ram; 87 88 /** 89 * Percentage of CPU used by the node. The value can be higher than 100 when the machine 90 * where the node is running has more than one CPU. 91 * If the value is `not a number` the node couldn't retrieve the amount of CPU used 92 * by its process. 93 */ 94 public float cpu; 95 96 public pure nothrow @safe void encode(Buffer buffer) { 97 with(buffer) { 98 writeBigEndianUshort(cast(ushort)name.length); writeString(name); 99 writeBigEndianFloat(tps); 100 writeBigEndianUlong(ram); 101 writeBigEndianFloat(cpu); 102 } 103 } 104 105 public pure nothrow @safe void decode(Buffer buffer) { 106 with(buffer) { 107 ushort bfz=readBigEndianUshort(); name=readString(bfz); 108 tps=readBigEndianFloat(); 109 ram=readBigEndianUlong(); 110 cpu=readBigEndianFloat(); 111 } 112 } 113 114 public string toString() { 115 return "NodeStats(name: " ~ std.conv.to!string(this.name) ~ ", tps: " ~ std.conv.to!string(this.tps) ~ ", ram: " ~ std.conv.to!string(this.ram) ~ ", cpu: " ~ std.conv.to!string(this.cpu) ~ ")"; 116 } 117 118 } 119