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/hncom2.xml 8 */ 9 /** 10 * Node-related packets and updates. 11 */ 12 module sul.protocol.hncom2.status; 13 14 import std.bitmanip : write, peek; 15 static import std.conv; 16 import std.system : Endian; 17 import std.typetuple : TypeTuple; 18 import std.typecons : Tuple; 19 import std.uuid : UUID; 20 21 import sul.utils.buffer; 22 import sul.utils.var; 23 24 static import sul.protocol.hncom2.types; 25 26 static if(__traits(compiles, { import sul.metadata.hncom2; })) import sul.metadata.hncom2; 27 28 alias Packets = TypeTuple!(AddNode, RemoveNode, MessageServerbound, MessageClientbound, Players, ResourcesUsage, Log, RemoteCommand, UpdateList, Reload); 29 30 /** 31 * Notifies the node that another node (that is not itself) has connected to the hub. 32 */ 33 class AddNode : Buffer { 34 35 public enum ubyte ID = 7; 36 37 public enum bool CLIENTBOUND = true; 38 public enum bool SERVERBOUND = false; 39 40 public enum string[] FIELDS = ["hubId", "name", "main", "acceptedGames"]; 41 42 /** 43 * Identifier given by the hub to uniquey identify the node. 44 */ 45 public uint hubId; 46 47 /** 48 * Node's name used for displaying and identification purposes. 49 */ 50 public string name; 51 52 /** 53 * Whether the node is a main node (see ConnectionRequest.main). 54 */ 55 public bool main; 56 57 /** 58 * Indicates the game accepted by the node. 59 */ 60 public sul.protocol.hncom2.types.Game[] acceptedGames; 61 62 public pure nothrow @safe @nogc this() {} 63 64 public pure nothrow @safe @nogc this(uint hubId, string name=string.init, bool main=bool.init, sul.protocol.hncom2.types.Game[] acceptedGames=(sul.protocol.hncom2.types.Game[]).init) { 65 this.hubId = hubId; 66 this.name = name; 67 this.main = main; 68 this.acceptedGames = acceptedGames; 69 } 70 71 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 72 _buffer.length = 0; 73 static if(writeId){ writeBigEndianUbyte(ID); } 74 writeBytes(varuint.encode(hubId)); 75 writeBytes(varuint.encode(cast(uint)name.length)); writeString(name); 76 writeBigEndianBool(main); 77 writeBytes(varuint.encode(cast(uint)acceptedGames.length)); foreach(ynzbzry1;acceptedGames){ ynzbzry1.encode(bufferInstance); } 78 return _buffer; 79 } 80 81 public pure nothrow @safe void decode(bool readId=true)() { 82 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 83 hubId=varuint.decode(_buffer, &_index); 84 uint bfz=varuint.decode(_buffer, &_index); name=readString(bfz); 85 main=readBigEndianBool(); 86 acceptedGames.length=varuint.decode(_buffer, &_index); foreach(ref ynzbzry1;acceptedGames){ ynzbzry1.decode(bufferInstance); } 87 } 88 89 public static pure nothrow @safe AddNode fromBuffer(bool readId=true)(ubyte[] buffer) { 90 AddNode ret = new AddNode(); 91 ret._buffer = buffer; 92 ret.decode!readId(); 93 return ret; 94 } 95 96 public override string toString() { 97 return "AddNode(hubId: " ~ std.conv.to!string(this.hubId) ~ ", name: " ~ std.conv.to!string(this.name) ~ ", main: " ~ std.conv.to!string(this.main) ~ ", acceptedGames: " ~ std.conv.to!string(this.acceptedGames) ~ ")"; 98 } 99 100 } 101 102 /** 103 * Notifies the node that another node, previously added with AddNode has disconnected 104 * from the hub. 105 */ 106 class RemoveNode : Buffer { 107 108 public enum ubyte ID = 8; 109 110 public enum bool CLIENTBOUND = true; 111 public enum bool SERVERBOUND = false; 112 113 public enum string[] FIELDS = ["hubId"]; 114 115 /** 116 * Node's id given by the hub. 117 */ 118 public uint hubId; 119 120 public pure nothrow @safe @nogc this() {} 121 122 public pure nothrow @safe @nogc this(uint hubId) { 123 this.hubId = hubId; 124 } 125 126 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 127 _buffer.length = 0; 128 static if(writeId){ writeBigEndianUbyte(ID); } 129 writeBytes(varuint.encode(hubId)); 130 return _buffer; 131 } 132 133 public pure nothrow @safe void decode(bool readId=true)() { 134 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 135 hubId=varuint.decode(_buffer, &_index); 136 } 137 138 public static pure nothrow @safe RemoveNode fromBuffer(bool readId=true)(ubyte[] buffer) { 139 RemoveNode ret = new RemoveNode(); 140 ret._buffer = buffer; 141 ret.decode!readId(); 142 return ret; 143 } 144 145 public override string toString() { 146 return "RemoveNode(hubId: " ~ std.conv.to!string(this.hubId) ~ ")"; 147 } 148 149 } 150 151 /** 152 * Sends a binary message to some selected nodes or broadcast it. 153 */ 154 class MessageServerbound : Buffer { 155 156 public enum ubyte ID = 9; 157 158 public enum bool CLIENTBOUND = false; 159 public enum bool SERVERBOUND = true; 160 161 public enum string[] FIELDS = ["addressees", "payload"]; 162 163 /** 164 * Addressees of the message. If the array is empty the message is broadcasted to every 165 * connected node. 166 */ 167 public uint[] addressees; 168 169 /** 170 * Bytes to be sent/broadcasted. It may be a serialised packet of a plugin-defined 171 * protocol. 172 */ 173 public ubyte[] payload; 174 175 public pure nothrow @safe @nogc this() {} 176 177 public pure nothrow @safe @nogc this(uint[] addressees, ubyte[] payload=(ubyte[]).init) { 178 this.addressees = addressees; 179 this.payload = payload; 180 } 181 182 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 183 _buffer.length = 0; 184 static if(writeId){ writeBigEndianUbyte(ID); } 185 writeBytes(varuint.encode(cast(uint)addressees.length)); foreach(yrcvcvc;addressees){ writeBytes(varuint.encode(yrcvcvc)); } 186 writeBytes(varuint.encode(cast(uint)payload.length)); writeBytes(payload); 187 return _buffer; 188 } 189 190 public pure nothrow @safe void decode(bool readId=true)() { 191 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 192 addressees.length=varuint.decode(_buffer, &_index); foreach(ref yrcvcvc;addressees){ yrcvcvc=varuint.decode(_buffer, &_index); } 193 payload.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+payload.length){ payload=_buffer[_index.._index+payload.length].dup; _index+=payload.length; } 194 } 195 196 public static pure nothrow @safe MessageServerbound fromBuffer(bool readId=true)(ubyte[] buffer) { 197 MessageServerbound ret = new MessageServerbound(); 198 ret._buffer = buffer; 199 ret.decode!readId(); 200 return ret; 201 } 202 203 public override string toString() { 204 return "MessageServerbound(addressees: " ~ std.conv.to!string(this.addressees) ~ ", payload: " ~ std.conv.to!string(this.payload) ~ ")"; 205 } 206 207 } 208 209 /** 210 * Receives a binary message sent by another node using MessageServerbound. 211 */ 212 class MessageClientbound : Buffer { 213 214 public enum ubyte ID = 10; 215 216 public enum bool CLIENTBOUND = true; 217 public enum bool SERVERBOUND = false; 218 219 public enum string[] FIELDS = ["sender", "payload"]; 220 221 /** 222 * Id of the node that has sent the message. 223 */ 224 public uint sender; 225 226 /** 227 * Bytes received. It could be a serialised packet of a plugin-defined packet. 228 */ 229 public ubyte[] payload; 230 231 public pure nothrow @safe @nogc this() {} 232 233 public pure nothrow @safe @nogc this(uint sender, ubyte[] payload=(ubyte[]).init) { 234 this.sender = sender; 235 this.payload = payload; 236 } 237 238 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 239 _buffer.length = 0; 240 static if(writeId){ writeBigEndianUbyte(ID); } 241 writeBytes(varuint.encode(sender)); 242 writeBytes(varuint.encode(cast(uint)payload.length)); writeBytes(payload); 243 return _buffer; 244 } 245 246 public pure nothrow @safe void decode(bool readId=true)() { 247 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 248 sender=varuint.decode(_buffer, &_index); 249 payload.length=varuint.decode(_buffer, &_index); if(_buffer.length>=_index+payload.length){ payload=_buffer[_index.._index+payload.length].dup; _index+=payload.length; } 250 } 251 252 public static pure nothrow @safe MessageClientbound fromBuffer(bool readId=true)(ubyte[] buffer) { 253 MessageClientbound ret = new MessageClientbound(); 254 ret._buffer = buffer; 255 ret.decode!readId(); 256 return ret; 257 } 258 259 public override string toString() { 260 return "MessageClientbound(sender: " ~ std.conv.to!string(this.sender) ~ ", payload: " ~ std.conv.to!string(this.payload) ~ ")"; 261 } 262 263 } 264 265 /** 266 * Updates the number of players on the server. 267 */ 268 class Players : Buffer { 269 270 public enum ubyte ID = 11; 271 272 public enum bool CLIENTBOUND = true; 273 public enum bool SERVERBOUND = false; 274 275 // max 276 public enum int UNLIMITED = -1; 277 278 public enum string[] FIELDS = ["online", "max"]; 279 280 /** 281 * Players currently online in the whole server (connected to a node). 282 */ 283 public uint online; 284 285 /** 286 * Maximum number of players that can connect to server. 287 */ 288 public int max; 289 290 public pure nothrow @safe @nogc this() {} 291 292 public pure nothrow @safe @nogc this(uint online, int max=int.init) { 293 this.online = online; 294 this.max = max; 295 } 296 297 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 298 _buffer.length = 0; 299 static if(writeId){ writeBigEndianUbyte(ID); } 300 writeBytes(varuint.encode(online)); 301 writeBytes(varint.encode(max)); 302 return _buffer; 303 } 304 305 public pure nothrow @safe void decode(bool readId=true)() { 306 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 307 online=varuint.decode(_buffer, &_index); 308 max=varint.decode(_buffer, &_index); 309 } 310 311 public static pure nothrow @safe Players fromBuffer(bool readId=true)(ubyte[] buffer) { 312 Players ret = new Players(); 313 ret._buffer = buffer; 314 ret.decode!readId(); 315 return ret; 316 } 317 318 public override string toString() { 319 return "Players(online: " ~ std.conv.to!string(this.online) ~ ", max: " ~ std.conv.to!string(this.max) ~ ")"; 320 } 321 322 } 323 324 /** 325 * Updates the usage of the system's resources of the node. 326 */ 327 class ResourcesUsage : Buffer { 328 329 public enum ubyte ID = 12; 330 331 public enum bool CLIENTBOUND = false; 332 public enum bool SERVERBOUND = true; 333 334 public enum string[] FIELDS = ["tps", "ram", "cpu"]; 335 336 /** 337 * Ticks per second of the node, in a range from 0 to 20, where a number lower than 338 * 20 indicates lag. 339 */ 340 public float tps; 341 342 /** 343 * Bytes of RAM used by the node. 344 */ 345 public ulong ram; 346 347 /** 348 * Percentage of CPU used by the node. It may be higher than 100 if the node has more 349 * than 1 CPU. 350 */ 351 public float cpu; 352 353 public pure nothrow @safe @nogc this() {} 354 355 public pure nothrow @safe @nogc this(float tps, ulong ram=ulong.init, float cpu=float.init) { 356 this.tps = tps; 357 this.ram = ram; 358 this.cpu = cpu; 359 } 360 361 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 362 _buffer.length = 0; 363 static if(writeId){ writeBigEndianUbyte(ID); } 364 writeBigEndianFloat(tps); 365 writeBytes(varulong.encode(ram)); 366 writeBigEndianFloat(cpu); 367 return _buffer; 368 } 369 370 public pure nothrow @safe void decode(bool readId=true)() { 371 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 372 tps=readBigEndianFloat(); 373 ram=varulong.decode(_buffer, &_index); 374 cpu=readBigEndianFloat(); 375 } 376 377 public static pure nothrow @safe ResourcesUsage fromBuffer(bool readId=true)(ubyte[] buffer) { 378 ResourcesUsage ret = new ResourcesUsage(); 379 ret._buffer = buffer; 380 ret.decode!readId(); 381 return ret; 382 } 383 384 public override string toString() { 385 return "ResourcesUsage(tps: " ~ std.conv.to!string(this.tps) ~ ", ram: " ~ std.conv.to!string(this.ram) ~ ", cpu: " ~ std.conv.to!string(this.cpu) ~ ")"; 386 } 387 388 } 389 390 /** 391 * Sends a log to the hub. 392 */ 393 class Log : Buffer { 394 395 public enum ubyte ID = 13; 396 397 public enum bool CLIENTBOUND = false; 398 public enum bool SERVERBOUND = true; 399 400 // world 401 public enum int NO_WORLD = -1; 402 403 public enum string[] FIELDS = ["timestamp", "world", "logger", "message", "commandId"]; 404 405 /** 406 * Unix time (in milliseconds) that indicates the exact creation time of the log (for 407 * ordering purposes). 408 */ 409 public ulong timestamp; 410 public int world; 411 412 /** 413 * Name of the logger thas has generated the log, if the log doesn't come from a world. 414 */ 415 public string logger; 416 417 /** 418 * Logged message. It may contain Minecraft formatting codes. 419 */ 420 public string message; 421 422 /** 423 * Identifier of the command that has generated the output or -1 if the log wasn't 424 * generated by a command. 425 */ 426 public int commandId; 427 428 public pure nothrow @safe @nogc this() {} 429 430 public pure nothrow @safe @nogc this(ulong timestamp, int world=int.init, string logger=string.init, string message=string.init, int commandId=int.init) { 431 this.timestamp = timestamp; 432 this.world = world; 433 this.logger = logger; 434 this.message = message; 435 this.commandId = commandId; 436 } 437 438 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 439 _buffer.length = 0; 440 static if(writeId){ writeBigEndianUbyte(ID); } 441 writeBytes(varulong.encode(timestamp)); 442 writeBytes(varint.encode(world)); 443 if(world<0){ writeBytes(varuint.encode(cast(uint)logger.length)); writeString(logger); } 444 writeBytes(varuint.encode(cast(uint)message.length)); writeString(message); 445 writeBytes(varint.encode(commandId)); 446 return _buffer; 447 } 448 449 public pure nothrow @safe void decode(bool readId=true)() { 450 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 451 timestamp=varulong.decode(_buffer, &_index); 452 world=varint.decode(_buffer, &_index); 453 if(world<0){ uint b9zv=varuint.decode(_buffer, &_index); logger=readString(b9zv); } 454 uint bvcfz=varuint.decode(_buffer, &_index); message=readString(bvcfz); 455 commandId=varint.decode(_buffer, &_index); 456 } 457 458 public static pure nothrow @safe Log fromBuffer(bool readId=true)(ubyte[] buffer) { 459 Log ret = new Log(); 460 ret._buffer = buffer; 461 ret.decode!readId(); 462 return ret; 463 } 464 465 public override string toString() { 466 return "Log(timestamp: " ~ std.conv.to!string(this.timestamp) ~ ", world: " ~ std.conv.to!string(this.world) ~ ", logger: " ~ std.conv.to!string(this.logger) ~ ", message: " ~ std.conv.to!string(this.message) ~ ", commandId: " ~ std.conv.to!string(this.commandId) ~ ")"; 467 } 468 469 } 470 471 /** 472 * Executes a command on the node. 473 */ 474 class RemoteCommand : Buffer { 475 476 public enum ubyte ID = 14; 477 478 public enum bool CLIENTBOUND = true; 479 public enum bool SERVERBOUND = false; 480 481 // origin 482 public enum ubyte HUB = 0; 483 public enum ubyte EXTERNAL_CONSOLE = 1; 484 public enum ubyte RCON = 2; 485 486 public enum string[] FIELDS = ["origin", "sender", "command", "commandId"]; 487 488 /** 489 * Origin of the command. It could be the hub itself or an external source. 490 */ 491 public ubyte origin; 492 493 /** 494 * Address of the sender if the command has been sent from an external source and not 495 * the hub. 496 */ 497 public sul.protocol.hncom2.types.Address sender; 498 499 /** 500 * Commands and arguments that should be executed on the node. For example `say hello 501 * world` or `transfer steve lobby12`. 502 */ 503 public string command; 504 505 /** 506 * Identifier of the command. It's sent in Log.commandId if the command generates an 507 * output. 508 */ 509 public int commandId; 510 511 public pure nothrow @safe @nogc this() {} 512 513 public pure nothrow @safe @nogc this(ubyte origin, sul.protocol.hncom2.types.Address sender=sul.protocol.hncom2.types.Address.init, string command=string.init, int commandId=int.init) { 514 this.origin = origin; 515 this.sender = sender; 516 this.command = command; 517 this.commandId = commandId; 518 } 519 520 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 521 _buffer.length = 0; 522 static if(writeId){ writeBigEndianUbyte(ID); } 523 writeBigEndianUbyte(origin); 524 if(origin!=0){ sender.encode(bufferInstance); } 525 writeBytes(varuint.encode(cast(uint)command.length)); writeString(command); 526 writeBytes(varint.encode(commandId)); 527 return _buffer; 528 } 529 530 public pure nothrow @safe void decode(bool readId=true)() { 531 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 532 origin=readBigEndianUbyte(); 533 if(origin!=0){ sender.decode(bufferInstance); } 534 uint y9bfz=varuint.decode(_buffer, &_index); command=readString(y9bfz); 535 commandId=varint.decode(_buffer, &_index); 536 } 537 538 public static pure nothrow @safe RemoteCommand fromBuffer(bool readId=true)(ubyte[] buffer) { 539 RemoteCommand ret = new RemoteCommand(); 540 ret._buffer = buffer; 541 ret.decode!readId(); 542 return ret; 543 } 544 545 public override string toString() { 546 return "RemoteCommand(origin: " ~ std.conv.to!string(this.origin) ~ ", sender: " ~ std.conv.to!string(this.sender) ~ ", command: " ~ std.conv.to!string(this.command) ~ ", commandId: " ~ std.conv.to!string(this.commandId) ~ ")"; 547 } 548 549 } 550 551 /** 552 * Updates a list. 553 */ 554 class UpdateList : Buffer { 555 556 public enum ubyte ID = 15; 557 558 public enum bool CLIENTBOUND = false; 559 public enum bool SERVERBOUND = true; 560 561 // list 562 public enum ubyte WHITELIST = 0; 563 public enum ubyte BLACKLIST = 1; 564 565 // action 566 public enum ubyte ADD = 0; 567 public enum ubyte REMOVE = 1; 568 569 public enum string[] FIELDS = ["list", "action", "type"]; 570 571 /** 572 * Type of the list to update. 573 */ 574 public ubyte list; 575 576 /** 577 * Whether to add or removed the player from the list. 578 */ 579 public ubyte action; 580 public ubyte type; 581 582 public pure nothrow @safe @nogc this() {} 583 584 public pure nothrow @safe @nogc this(ubyte list, ubyte action=ubyte.init, ubyte type=ubyte.init) { 585 this.list = list; 586 this.action = action; 587 this.type = type; 588 } 589 590 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 591 _buffer.length = 0; 592 static if(writeId){ writeBigEndianUbyte(ID); } 593 writeBigEndianUbyte(list); 594 writeBigEndianUbyte(action); 595 writeBigEndianUbyte(type); 596 return _buffer; 597 } 598 599 public pure nothrow @safe void decode(bool readId=true)() { 600 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 601 list=readBigEndianUbyte(); 602 action=readBigEndianUbyte(); 603 type=readBigEndianUbyte(); 604 } 605 606 public static pure nothrow @safe UpdateList fromBuffer(bool readId=true)(ubyte[] buffer) { 607 UpdateList ret = new UpdateList(); 608 ret._buffer = buffer; 609 ret.decode!readId(); 610 return ret; 611 } 612 613 public override string toString() { 614 return "UpdateList(list: " ~ std.conv.to!string(this.list) ~ ", action: " ~ std.conv.to!string(this.action) ~ ", type: " ~ std.conv.to!string(this.type) ~ ")"; 615 } 616 617 alias _encode = encode; 618 619 enum string variantField = "type"; 620 621 alias Variants = TypeTuple!(ByHubId, ByName, ByUuid); 622 623 public class ByHubId { 624 625 public enum typeof(type) TYPE = 0; 626 627 public enum string[] FIELDS = ["hubId"]; 628 629 public uint hubId; 630 631 public pure nothrow @safe @nogc this() {} 632 633 public pure nothrow @safe @nogc this(uint hubId) { 634 this.hubId = hubId; 635 } 636 637 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 638 type = 0; 639 _encode!writeId(); 640 writeBytes(varuint.encode(hubId)); 641 return _buffer; 642 } 643 644 public pure nothrow @safe void decode() { 645 hubId=varuint.decode(_buffer, &_index); 646 } 647 648 public override string toString() { 649 return "UpdateList.ByHubId(hubId: " ~ std.conv.to!string(this.hubId) ~ ")"; 650 } 651 652 } 653 654 public class ByName { 655 656 public enum typeof(type) TYPE = 1; 657 658 public enum string[] FIELDS = ["username"]; 659 660 /** 661 * Case-insensitive player's username. Spaces may be replaced by dashes. 662 */ 663 public string username; 664 665 public pure nothrow @safe @nogc this() {} 666 667 public pure nothrow @safe @nogc this(string username) { 668 this.username = username; 669 } 670 671 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 672 type = 1; 673 _encode!writeId(); 674 writeBytes(varuint.encode(cast(uint)username.length)); writeString(username); 675 return _buffer; 676 } 677 678 public pure nothrow @safe void decode() { 679 uint dnc5bu=varuint.decode(_buffer, &_index); username=readString(dnc5bu); 680 } 681 682 public override string toString() { 683 return "UpdateList.ByName(username: " ~ std.conv.to!string(this.username) ~ ")"; 684 } 685 686 } 687 688 public class ByUuid { 689 690 public enum typeof(type) TYPE = 2; 691 692 // game 693 public enum ubyte POCKET = 1; 694 public enum ubyte MINECRAFT = 2; 695 public enum ubyte CONSOLE = 3; 696 697 public enum string[] FIELDS = ["game", "uuid"]; 698 699 public ubyte game; 700 public UUID uuid; 701 702 public pure nothrow @safe @nogc this() {} 703 704 public pure nothrow @safe @nogc this(ubyte game, UUID uuid=UUID.init) { 705 this.game = game; 706 this.uuid = uuid; 707 } 708 709 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 710 type = 2; 711 _encode!writeId(); 712 writeBigEndianUbyte(game); 713 writeBytes(uuid.data); 714 return _buffer; 715 } 716 717 public pure nothrow @safe void decode() { 718 game=readBigEndianUbyte(); 719 if(_buffer.length>=_index+16){ ubyte[16] dvz=_buffer[_index.._index+16].dup; _index+=16; uuid=UUID(dvz); } 720 } 721 722 public override string toString() { 723 return "UpdateList.ByUuid(game: " ~ std.conv.to!string(this.game) ~ ", uuid: " ~ std.conv.to!string(this.uuid) ~ ")"; 724 } 725 726 } 727 728 } 729 730 /** 731 * Notifies the node that the hub's reloadeable settings have been reloaded and that 732 * the node should also reload its resources (for example plugin's settings). 733 * The fields of the packet may be empty if not updated during the reload. 734 */ 735 class Reload : Buffer { 736 737 public enum ubyte ID = 16; 738 739 public enum bool CLIENTBOUND = true; 740 public enum bool SERVERBOUND = false; 741 742 public enum string[] FIELDS = ["displayName", "motds", "language", "acceptedLanguages", "socialJson"]; 743 744 /** 745 * Display name of the server, same as HubInfo.displayName. 746 */ 747 public string displayName; 748 749 /** 750 * New MOTDs (message of the day) for the supported games. 751 */ 752 public sul.protocol.hncom2.types.Motd[] motds; 753 754 /** 755 * Main language of the server, in the same format as HubInfo.language. 756 */ 757 public string language; 758 public string[] acceptedLanguages; 759 public string socialJson; 760 761 public pure nothrow @safe @nogc this() {} 762 763 public pure nothrow @safe @nogc this(string displayName, sul.protocol.hncom2.types.Motd[] motds=(sul.protocol.hncom2.types.Motd[]).init, string language=string.init, string[] acceptedLanguages=(string[]).init, string socialJson=string.init) { 764 this.displayName = displayName; 765 this.motds = motds; 766 this.language = language; 767 this.acceptedLanguages = acceptedLanguages; 768 this.socialJson = socialJson; 769 } 770 771 public pure nothrow @safe ubyte[] encode(bool writeId=true)() { 772 _buffer.length = 0; 773 static if(writeId){ writeBigEndianUbyte(ID); } 774 writeBytes(varuint.encode(cast(uint)displayName.length)); writeString(displayName); 775 writeBytes(varuint.encode(cast(uint)motds.length)); foreach(b9zm;motds){ b9zm.encode(bufferInstance); } 776 writeBytes(varuint.encode(cast(uint)language.length)); writeString(language); 777 writeBytes(varuint.encode(cast(uint)acceptedLanguages.length)); foreach(ynzbzry5;acceptedLanguages){ writeBytes(varuint.encode(cast(uint)ynzbzry5.length)); writeString(ynzbzry5); } 778 writeBytes(varuint.encode(cast(uint)socialJson.length)); writeString(socialJson); 779 return _buffer; 780 } 781 782 public pure nothrow @safe void decode(bool readId=true)() { 783 static if(readId){ ubyte _id; _id=readBigEndianUbyte(); } 784 uint zlcxe5bu=varuint.decode(_buffer, &_index); displayName=readString(zlcxe5bu); 785 motds.length=varuint.decode(_buffer, &_index); foreach(ref b9zm;motds){ b9zm.decode(bufferInstance); } 786 uint bfzvzu=varuint.decode(_buffer, &_index); language=readString(bfzvzu); 787 acceptedLanguages.length=varuint.decode(_buffer, &_index); foreach(ref ynzbzry5;acceptedLanguages){ uint e5ypeu=varuint.decode(_buffer, &_index); ynzbzry5=readString(e5ypeu); } 788 uint c9afsnb=varuint.decode(_buffer, &_index); socialJson=readString(c9afsnb); 789 } 790 791 public static pure nothrow @safe Reload fromBuffer(bool readId=true)(ubyte[] buffer) { 792 Reload ret = new Reload(); 793 ret._buffer = buffer; 794 ret.decode!readId(); 795 return ret; 796 } 797 798 public override string toString() { 799 return "Reload(displayName: " ~ std.conv.to!string(this.displayName) ~ ", motds: " ~ std.conv.to!string(this.motds) ~ ", language: " ~ std.conv.to!string(this.language) ~ ", acceptedLanguages: " ~ std.conv.to!string(this.acceptedLanguages) ~ ", socialJson: " ~ std.conv.to!string(this.socialJson) ~ ")"; 800 } 801 802 } 803