diff --git a/netty/server/.gitignore b/netty/.gitignore
similarity index 100%
rename from netty/server/.gitignore
rename to netty/.gitignore
diff --git a/netty/client/.gitignore b/netty/client/.gitignore
deleted file mode 100644
index 485dee6..0000000
--- a/netty/client/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-.idea
diff --git a/netty/client/index.html b/netty/client/index.html
index e080a80..4c0af36 100644
--- a/netty/client/index.html
+++ b/netty/client/index.html
@@ -4,7 +4,7 @@
Title
-
+
diff --git a/netty/client/sample_generated.js b/netty/client/sample_generated.js
deleted file mode 100644
index 3ac7c81..0000000
--- a/netty/client/sample_generated.js
+++ /dev/null
@@ -1,575 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-/**
- * @const
- * @namespace
- */
-var MyGame = MyGame || {};
-
-/**
- * @const
- * @namespace
- */
-MyGame.Sample = MyGame.Sample || {};
-
-/**
- * @enum {number}
- */
-MyGame.Sample.Color = {
- Red: 0,
- Green: 1,
- Blue: 2
-};
-
-/**
- * @enum {string}
- */
-MyGame.Sample.ColorName = {
- '0': 'Red',
- '1': 'Green',
- '2': 'Blue'
-};
-
-/**
- * @enum {number}
- */
-MyGame.Sample.Equipment = {
- NONE: 0,
- Weapon: 1
-};
-
-/**
- * @enum {string}
- */
-MyGame.Sample.EquipmentName = {
- '0': 'NONE',
- '1': 'Weapon'
-};
-
-/**
- * @constructor
- */
-MyGame.Sample.Vec3 = function() {
- /**
- * @type {flatbuffers.ByteBuffer}
- */
- this.bb = null;
-
- /**
- * @type {number}
- */
- this.bb_pos = 0;
-};
-
-/**
- * @param {number} i
- * @param {flatbuffers.ByteBuffer} bb
- * @returns {MyGame.Sample.Vec3}
- */
-MyGame.Sample.Vec3.prototype.__init = function(i, bb) {
- this.bb_pos = i;
- this.bb = bb;
- return this;
-};
-
-/**
- * @returns {number}
- */
-MyGame.Sample.Vec3.prototype.x = function() {
- return this.bb.readFloat32(this.bb_pos);
-};
-
-/**
- * @returns {number}
- */
-MyGame.Sample.Vec3.prototype.y = function() {
- return this.bb.readFloat32(this.bb_pos + 4);
-};
-
-/**
- * @returns {number}
- */
-MyGame.Sample.Vec3.prototype.z = function() {
- return this.bb.readFloat32(this.bb_pos + 8);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} x
- * @param {number} y
- * @param {number} z
- * @returns {flatbuffers.Offset}
- */
-MyGame.Sample.Vec3.createVec3 = function(builder, x, y, z) {
- builder.prep(4, 12);
- builder.writeFloat32(z);
- builder.writeFloat32(y);
- builder.writeFloat32(x);
- return builder.offset();
-};
-
-/**
- * @constructor
- */
-MyGame.Sample.Monster = function() {
- /**
- * @type {flatbuffers.ByteBuffer}
- */
- this.bb = null;
-
- /**
- * @type {number}
- */
- this.bb_pos = 0;
-};
-
-/**
- * @param {number} i
- * @param {flatbuffers.ByteBuffer} bb
- * @returns {MyGame.Sample.Monster}
- */
-MyGame.Sample.Monster.prototype.__init = function(i, bb) {
- this.bb_pos = i;
- this.bb = bb;
- return this;
-};
-
-/**
- * @param {flatbuffers.ByteBuffer} bb
- * @param {MyGame.Sample.Monster=} obj
- * @returns {MyGame.Sample.Monster}
- */
-MyGame.Sample.Monster.getRootAsMonster = function(bb, obj) {
- return (obj || new MyGame.Sample.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
-};
-
-/**
- * @param {flatbuffers.ByteBuffer} bb
- * @param {MyGame.Sample.Monster=} obj
- * @returns {MyGame.Sample.Monster}
- */
-MyGame.Sample.Monster.getSizePrefixedRootAsMonster = function(bb, obj) {
- bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
- return (obj || new MyGame.Sample.Monster).__init(bb.readInt32(bb.position()) + bb.position(), bb);
-};
-
-/**
- * @param {MyGame.Sample.Vec3=} obj
- * @returns {MyGame.Sample.Vec3|null}
- */
-MyGame.Sample.Monster.prototype.pos = function(obj) {
- var offset = this.bb.__offset(this.bb_pos, 4);
- return offset ? (obj || new MyGame.Sample.Vec3).__init(this.bb_pos + offset, this.bb) : null;
-};
-
-/**
- * @returns {number}
- */
-MyGame.Sample.Monster.prototype.mana = function() {
- var offset = this.bb.__offset(this.bb_pos, 6);
- return offset ? this.bb.readInt16(this.bb_pos + offset) : 150;
-};
-
-/**
- * @returns {number}
- */
-MyGame.Sample.Monster.prototype.hp = function() {
- var offset = this.bb.__offset(this.bb_pos, 8);
- return offset ? this.bb.readInt16(this.bb_pos + offset) : 100;
-};
-
-/**
- * @param {flatbuffers.Encoding=} optionalEncoding
- * @returns {string|Uint8Array|null}
- */
-MyGame.Sample.Monster.prototype.name = function(optionalEncoding) {
- var offset = this.bb.__offset(this.bb_pos, 10);
- return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
-};
-
-/**
- * @param {number} index
- * @returns {number}
- */
-MyGame.Sample.Monster.prototype.inventory = function(index) {
- var offset = this.bb.__offset(this.bb_pos, 14);
- return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
-};
-
-/**
- * @returns {number}
- */
-MyGame.Sample.Monster.prototype.inventoryLength = function() {
- var offset = this.bb.__offset(this.bb_pos, 14);
- return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns {Uint8Array}
- */
-MyGame.Sample.Monster.prototype.inventoryArray = function() {
- var offset = this.bb.__offset(this.bb_pos, 14);
- return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
-};
-
-/**
- * @returns {MyGame.Sample.Color}
- */
-MyGame.Sample.Monster.prototype.color = function() {
- var offset = this.bb.__offset(this.bb_pos, 16);
- return offset ? /** @type {MyGame.Sample.Color} */ (this.bb.readInt8(this.bb_pos + offset)) : MyGame.Sample.Color.Blue;
-};
-
-/**
- * @param {number} index
- * @param {MyGame.Sample.Weapon=} obj
- * @returns {MyGame.Sample.Weapon}
- */
-MyGame.Sample.Monster.prototype.weapons = function(index, obj) {
- var offset = this.bb.__offset(this.bb_pos, 18);
- return offset ? (obj || new MyGame.Sample.Weapon).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null;
-};
-
-/**
- * @returns {number}
- */
-MyGame.Sample.Monster.prototype.weaponsLength = function() {
- var offset = this.bb.__offset(this.bb_pos, 18);
- return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
-};
-
-/**
- * @returns {MyGame.Sample.Equipment}
- */
-MyGame.Sample.Monster.prototype.equippedType = function() {
- var offset = this.bb.__offset(this.bb_pos, 20);
- return offset ? /** @type {MyGame.Sample.Equipment} */ (this.bb.readUint8(this.bb_pos + offset)) : MyGame.Sample.Equipment.NONE;
-};
-
-/**
- * @param {flatbuffers.Table} obj
- * @returns {?flatbuffers.Table}
- */
-MyGame.Sample.Monster.prototype.equipped = function(obj) {
- var offset = this.bb.__offset(this.bb_pos, 22);
- return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
-};
-
-/**
- * @param {number} index
- * @param {MyGame.Sample.Vec3=} obj
- * @returns {MyGame.Sample.Vec3}
- */
-MyGame.Sample.Monster.prototype.path = function(index, obj) {
- var offset = this.bb.__offset(this.bb_pos, 24);
- return offset ? (obj || new MyGame.Sample.Vec3).__init(this.bb.__vector(this.bb_pos + offset) + index * 12, this.bb) : null;
-};
-
-/**
- * @returns {number}
- */
-MyGame.Sample.Monster.prototype.pathLength = function() {
- var offset = this.bb.__offset(this.bb_pos, 24);
- return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- */
-MyGame.Sample.Monster.startMonster = function(builder) {
- builder.startObject(11);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} posOffset
- */
-MyGame.Sample.Monster.addPos = function(builder, posOffset) {
- builder.addFieldStruct(0, posOffset, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} mana
- */
-MyGame.Sample.Monster.addMana = function(builder, mana) {
- builder.addFieldInt16(1, mana, 150);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} hp
- */
-MyGame.Sample.Monster.addHp = function(builder, hp) {
- builder.addFieldInt16(2, hp, 100);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} nameOffset
- */
-MyGame.Sample.Monster.addName = function(builder, nameOffset) {
- builder.addFieldOffset(3, nameOffset, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} inventoryOffset
- */
-MyGame.Sample.Monster.addInventory = function(builder, inventoryOffset) {
- builder.addFieldOffset(5, inventoryOffset, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {Array.} data
- * @returns {flatbuffers.Offset}
- */
-MyGame.Sample.Monster.createInventoryVector = function(builder, data) {
- builder.startVector(1, data.length, 1);
- for (var i = data.length - 1; i >= 0; i--) {
- builder.addInt8(data[i]);
- }
- return builder.endVector();
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} numElems
- */
-MyGame.Sample.Monster.startInventoryVector = function(builder, numElems) {
- builder.startVector(1, numElems, 1);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {MyGame.Sample.Color} color
- */
-MyGame.Sample.Monster.addColor = function(builder, color) {
- builder.addFieldInt8(6, color, MyGame.Sample.Color.Blue);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} weaponsOffset
- */
-MyGame.Sample.Monster.addWeapons = function(builder, weaponsOffset) {
- builder.addFieldOffset(7, weaponsOffset, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {Array.} data
- * @returns {flatbuffers.Offset}
- */
-MyGame.Sample.Monster.createWeaponsVector = function(builder, data) {
- builder.startVector(4, data.length, 4);
- for (var i = data.length - 1; i >= 0; i--) {
- builder.addOffset(data[i]);
- }
- return builder.endVector();
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} numElems
- */
-MyGame.Sample.Monster.startWeaponsVector = function(builder, numElems) {
- builder.startVector(4, numElems, 4);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {MyGame.Sample.Equipment} equippedType
- */
-MyGame.Sample.Monster.addEquippedType = function(builder, equippedType) {
- builder.addFieldInt8(8, equippedType, MyGame.Sample.Equipment.NONE);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} equippedOffset
- */
-MyGame.Sample.Monster.addEquipped = function(builder, equippedOffset) {
- builder.addFieldOffset(9, equippedOffset, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} pathOffset
- */
-MyGame.Sample.Monster.addPath = function(builder, pathOffset) {
- builder.addFieldOffset(10, pathOffset, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} numElems
- */
-MyGame.Sample.Monster.startPathVector = function(builder, numElems) {
- builder.startVector(12, numElems, 4);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @returns {flatbuffers.Offset}
- */
-MyGame.Sample.Monster.endMonster = function(builder) {
- var offset = builder.endObject();
- return offset;
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} offset
- */
-MyGame.Sample.Monster.finishMonsterBuffer = function(builder, offset) {
- builder.finish(offset);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} offset
- */
-MyGame.Sample.Monster.finishSizePrefixedMonsterBuffer = function(builder, offset) {
- builder.finish(offset, undefined, true);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} posOffset
- * @param {number} mana
- * @param {number} hp
- * @param {flatbuffers.Offset} nameOffset
- * @param {flatbuffers.Offset} inventoryOffset
- * @param {MyGame.Sample.Color} color
- * @param {flatbuffers.Offset} weaponsOffset
- * @param {MyGame.Sample.Equipment} equippedType
- * @param {flatbuffers.Offset} equippedOffset
- * @param {flatbuffers.Offset} pathOffset
- * @returns {flatbuffers.Offset}
- */
-MyGame.Sample.Monster.createMonster = function(builder, posOffset, mana, hp, nameOffset, inventoryOffset, color, weaponsOffset, equippedType, equippedOffset, pathOffset) {
- MyGame.Sample.Monster.startMonster(builder);
- MyGame.Sample.Monster.addPos(builder, posOffset);
- MyGame.Sample.Monster.addMana(builder, mana);
- MyGame.Sample.Monster.addHp(builder, hp);
- MyGame.Sample.Monster.addName(builder, nameOffset);
- MyGame.Sample.Monster.addInventory(builder, inventoryOffset);
- MyGame.Sample.Monster.addColor(builder, color);
- MyGame.Sample.Monster.addWeapons(builder, weaponsOffset);
- MyGame.Sample.Monster.addEquippedType(builder, equippedType);
- MyGame.Sample.Monster.addEquipped(builder, equippedOffset);
- MyGame.Sample.Monster.addPath(builder, pathOffset);
- return MyGame.Sample.Monster.endMonster(builder);
-}
-
-/**
- * @constructor
- */
-MyGame.Sample.Weapon = function() {
- /**
- * @type {flatbuffers.ByteBuffer}
- */
- this.bb = null;
-
- /**
- * @type {number}
- */
- this.bb_pos = 0;
-};
-
-/**
- * @param {number} i
- * @param {flatbuffers.ByteBuffer} bb
- * @returns {MyGame.Sample.Weapon}
- */
-MyGame.Sample.Weapon.prototype.__init = function(i, bb) {
- this.bb_pos = i;
- this.bb = bb;
- return this;
-};
-
-/**
- * @param {flatbuffers.ByteBuffer} bb
- * @param {MyGame.Sample.Weapon=} obj
- * @returns {MyGame.Sample.Weapon}
- */
-MyGame.Sample.Weapon.getRootAsWeapon = function(bb, obj) {
- return (obj || new MyGame.Sample.Weapon).__init(bb.readInt32(bb.position()) + bb.position(), bb);
-};
-
-/**
- * @param {flatbuffers.ByteBuffer} bb
- * @param {MyGame.Sample.Weapon=} obj
- * @returns {MyGame.Sample.Weapon}
- */
-MyGame.Sample.Weapon.getSizePrefixedRootAsWeapon = function(bb, obj) {
- bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
- return (obj || new MyGame.Sample.Weapon).__init(bb.readInt32(bb.position()) + bb.position(), bb);
-};
-
-/**
- * @param {flatbuffers.Encoding=} optionalEncoding
- * @returns {string|Uint8Array|null}
- */
-MyGame.Sample.Weapon.prototype.name = function(optionalEncoding) {
- var offset = this.bb.__offset(this.bb_pos, 4);
- return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
-};
-
-/**
- * @returns {number}
- */
-MyGame.Sample.Weapon.prototype.damage = function() {
- var offset = this.bb.__offset(this.bb_pos, 6);
- return offset ? this.bb.readInt16(this.bb_pos + offset) : 0;
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- */
-MyGame.Sample.Weapon.startWeapon = function(builder) {
- builder.startObject(2);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} nameOffset
- */
-MyGame.Sample.Weapon.addName = function(builder, nameOffset) {
- builder.addFieldOffset(0, nameOffset, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {number} damage
- */
-MyGame.Sample.Weapon.addDamage = function(builder, damage) {
- builder.addFieldInt16(1, damage, 0);
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @returns {flatbuffers.Offset}
- */
-MyGame.Sample.Weapon.endWeapon = function(builder) {
- var offset = builder.endObject();
- return offset;
-};
-
-/**
- * @param {flatbuffers.Builder} builder
- * @param {flatbuffers.Offset} nameOffset
- * @param {number} damage
- * @returns {flatbuffers.Offset}
- */
-MyGame.Sample.Weapon.createWeapon = function(builder, nameOffset, damage) {
- MyGame.Sample.Weapon.startWeapon(builder);
- MyGame.Sample.Weapon.addName(builder, nameOffset);
- MyGame.Sample.Weapon.addDamage(builder, damage);
- return MyGame.Sample.Weapon.endWeapon(builder);
-}
-
-// Exports for Node.js and RequireJS
-this.MyGame = MyGame;
diff --git a/netty/client/schema_generated.js b/netty/client/schema_generated.js
new file mode 100644
index 0000000..b9b6a8e
--- /dev/null
+++ b/netty/client/schema_generated.js
@@ -0,0 +1,561 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+
+/**
+ * @const
+ * @namespace
+ */
+var com = com || {};
+
+/**
+ * @const
+ * @namespace
+ */
+com.miti99 = com.miti99 || {};
+
+/**
+ * @const
+ * @namespace
+ */
+com.miti99.netty = com.miti99.netty || {};
+
+/**
+ * @const
+ * @namespace
+ */
+com.miti99.netty.fbs = com.miti99.netty.fbs || {};
+
+/**
+ * @enum {number}
+ */
+com.miti99.netty.fbs.PacketData = {
+ NONE: 0,
+ LoginRequest: 1,
+ LoginResponse: 2
+};
+
+/**
+ * @enum {string}
+ */
+com.miti99.netty.fbs.PacketDataName = {
+ '0': 'NONE',
+ '1': 'LoginRequest',
+ '2': 'LoginResponse'
+};
+
+/**
+ * @constructor
+ */
+com.miti99.netty.fbs.Vec2 = function() {
+ /**
+ * @type {flatbuffers.ByteBuffer}
+ */
+ this.bb = null;
+
+ /**
+ * @type {number}
+ */
+ this.bb_pos = 0;
+};
+
+/**
+ * @param {number} i
+ * @param {flatbuffers.ByteBuffer} bb
+ * @returns {com.miti99.netty.fbs.Vec2}
+ */
+com.miti99.netty.fbs.Vec2.prototype.__init = function(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+};
+
+/**
+ * @returns {number}
+ */
+com.miti99.netty.fbs.Vec2.prototype.x = function() {
+ return this.bb.readFloat64(this.bb_pos);
+};
+
+/**
+ * @returns {number}
+ */
+com.miti99.netty.fbs.Vec2.prototype.y = function() {
+ return this.bb.readFloat64(this.bb_pos + 8);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {number} x
+ * @param {number} y
+ * @returns {flatbuffers.Offset}
+ */
+com.miti99.netty.fbs.Vec2.createVec2 = function(builder, x, y) {
+ builder.prep(8, 16);
+ builder.writeFloat64(y);
+ builder.writeFloat64(x);
+ return builder.offset();
+};
+
+/**
+ * @constructor
+ */
+com.miti99.netty.fbs.Player = function() {
+ /**
+ * @type {flatbuffers.ByteBuffer}
+ */
+ this.bb = null;
+
+ /**
+ * @type {number}
+ */
+ this.bb_pos = 0;
+};
+
+/**
+ * @param {number} i
+ * @param {flatbuffers.ByteBuffer} bb
+ * @returns {com.miti99.netty.fbs.Player}
+ */
+com.miti99.netty.fbs.Player.prototype.__init = function(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+};
+
+/**
+ * @param {flatbuffers.ByteBuffer} bb
+ * @param {com.miti99.netty.fbs.Player=} obj
+ * @returns {com.miti99.netty.fbs.Player}
+ */
+com.miti99.netty.fbs.Player.getRootAsPlayer = function(bb, obj) {
+ return (obj || new com.miti99.netty.fbs.Player).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+};
+
+/**
+ * @param {flatbuffers.ByteBuffer} bb
+ * @param {com.miti99.netty.fbs.Player=} obj
+ * @returns {com.miti99.netty.fbs.Player}
+ */
+com.miti99.netty.fbs.Player.getSizePrefixedRootAsPlayer = function(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new com.miti99.netty.fbs.Player).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+};
+
+/**
+ * @returns {number}
+ */
+com.miti99.netty.fbs.Player.prototype.userId = function() {
+ var offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+};
+
+/**
+ * @param {flatbuffers.Encoding=} optionalEncoding
+ * @returns {string|Uint8Array|null}
+ */
+com.miti99.netty.fbs.Player.prototype.userName = function(optionalEncoding) {
+ var offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
+};
+
+/**
+ * @param {com.miti99.netty.fbs.Vec2=} obj
+ * @returns {com.miti99.netty.fbs.Vec2|null}
+ */
+com.miti99.netty.fbs.Player.prototype.position = function(obj) {
+ var offset = this.bb.__offset(this.bb_pos, 8);
+ return offset ? (obj || new com.miti99.netty.fbs.Vec2).__init(this.bb_pos + offset, this.bb) : null;
+};
+
+/**
+ * @returns {number}
+ */
+com.miti99.netty.fbs.Player.prototype.rotation = function() {
+ var offset = this.bb.__offset(this.bb_pos, 10);
+ return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
+};
+
+/**
+ * @returns {number}
+ */
+com.miti99.netty.fbs.Player.prototype.team = function() {
+ var offset = this.bb.__offset(this.bb_pos, 12);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ */
+com.miti99.netty.fbs.Player.startPlayer = function(builder) {
+ builder.startObject(5);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {number} userId
+ */
+com.miti99.netty.fbs.Player.addUserId = function(builder, userId) {
+ builder.addFieldInt32(0, userId, 0);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} userNameOffset
+ */
+com.miti99.netty.fbs.Player.addUserName = function(builder, userNameOffset) {
+ builder.addFieldOffset(1, userNameOffset, 0);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} positionOffset
+ */
+com.miti99.netty.fbs.Player.addPosition = function(builder, positionOffset) {
+ builder.addFieldStruct(2, positionOffset, 0);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {number} rotation
+ */
+com.miti99.netty.fbs.Player.addRotation = function(builder, rotation) {
+ builder.addFieldFloat64(3, rotation, 0.0);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {number} team
+ */
+com.miti99.netty.fbs.Player.addTeam = function(builder, team) {
+ builder.addFieldInt32(4, team, 0);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @returns {flatbuffers.Offset}
+ */
+com.miti99.netty.fbs.Player.endPlayer = function(builder) {
+ var offset = builder.endObject();
+ return offset;
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {number} userId
+ * @param {flatbuffers.Offset} userNameOffset
+ * @param {flatbuffers.Offset} positionOffset
+ * @param {number} rotation
+ * @param {number} team
+ * @returns {flatbuffers.Offset}
+ */
+com.miti99.netty.fbs.Player.createPlayer = function(builder, userId, userNameOffset, positionOffset, rotation, team) {
+ com.miti99.netty.fbs.Player.startPlayer(builder);
+ com.miti99.netty.fbs.Player.addUserId(builder, userId);
+ com.miti99.netty.fbs.Player.addUserName(builder, userNameOffset);
+ com.miti99.netty.fbs.Player.addPosition(builder, positionOffset);
+ com.miti99.netty.fbs.Player.addRotation(builder, rotation);
+ com.miti99.netty.fbs.Player.addTeam(builder, team);
+ return com.miti99.netty.fbs.Player.endPlayer(builder);
+}
+
+/**
+ * @constructor
+ */
+com.miti99.netty.fbs.LoginRequest = function() {
+ /**
+ * @type {flatbuffers.ByteBuffer}
+ */
+ this.bb = null;
+
+ /**
+ * @type {number}
+ */
+ this.bb_pos = 0;
+};
+
+/**
+ * @param {number} i
+ * @param {flatbuffers.ByteBuffer} bb
+ * @returns {com.miti99.netty.fbs.LoginRequest}
+ */
+com.miti99.netty.fbs.LoginRequest.prototype.__init = function(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+};
+
+/**
+ * @param {flatbuffers.ByteBuffer} bb
+ * @param {com.miti99.netty.fbs.LoginRequest=} obj
+ * @returns {com.miti99.netty.fbs.LoginRequest}
+ */
+com.miti99.netty.fbs.LoginRequest.getRootAsLoginRequest = function(bb, obj) {
+ return (obj || new com.miti99.netty.fbs.LoginRequest).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+};
+
+/**
+ * @param {flatbuffers.ByteBuffer} bb
+ * @param {com.miti99.netty.fbs.LoginRequest=} obj
+ * @returns {com.miti99.netty.fbs.LoginRequest}
+ */
+com.miti99.netty.fbs.LoginRequest.getSizePrefixedRootAsLoginRequest = function(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new com.miti99.netty.fbs.LoginRequest).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+};
+
+/**
+ * @returns {number}
+ */
+com.miti99.netty.fbs.LoginRequest.prototype.userId = function() {
+ var offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ */
+com.miti99.netty.fbs.LoginRequest.startLoginRequest = function(builder) {
+ builder.startObject(1);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {number} userId
+ */
+com.miti99.netty.fbs.LoginRequest.addUserId = function(builder, userId) {
+ builder.addFieldInt32(0, userId, 0);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @returns {flatbuffers.Offset}
+ */
+com.miti99.netty.fbs.LoginRequest.endLoginRequest = function(builder) {
+ var offset = builder.endObject();
+ return offset;
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {number} userId
+ * @returns {flatbuffers.Offset}
+ */
+com.miti99.netty.fbs.LoginRequest.createLoginRequest = function(builder, userId) {
+ com.miti99.netty.fbs.LoginRequest.startLoginRequest(builder);
+ com.miti99.netty.fbs.LoginRequest.addUserId(builder, userId);
+ return com.miti99.netty.fbs.LoginRequest.endLoginRequest(builder);
+}
+
+/**
+ * @constructor
+ */
+com.miti99.netty.fbs.LoginResponse = function() {
+ /**
+ * @type {flatbuffers.ByteBuffer}
+ */
+ this.bb = null;
+
+ /**
+ * @type {number}
+ */
+ this.bb_pos = 0;
+};
+
+/**
+ * @param {number} i
+ * @param {flatbuffers.ByteBuffer} bb
+ * @returns {com.miti99.netty.fbs.LoginResponse}
+ */
+com.miti99.netty.fbs.LoginResponse.prototype.__init = function(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+};
+
+/**
+ * @param {flatbuffers.ByteBuffer} bb
+ * @param {com.miti99.netty.fbs.LoginResponse=} obj
+ * @returns {com.miti99.netty.fbs.LoginResponse}
+ */
+com.miti99.netty.fbs.LoginResponse.getRootAsLoginResponse = function(bb, obj) {
+ return (obj || new com.miti99.netty.fbs.LoginResponse).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+};
+
+/**
+ * @param {flatbuffers.ByteBuffer} bb
+ * @param {com.miti99.netty.fbs.LoginResponse=} obj
+ * @returns {com.miti99.netty.fbs.LoginResponse}
+ */
+com.miti99.netty.fbs.LoginResponse.getSizePrefixedRootAsLoginResponse = function(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new com.miti99.netty.fbs.LoginResponse).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+};
+
+/**
+ * @param {com.miti99.netty.fbs.Player=} obj
+ * @returns {com.miti99.netty.fbs.Player|null}
+ */
+com.miti99.netty.fbs.LoginResponse.prototype.player = function(obj) {
+ var offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? (obj || new com.miti99.netty.fbs.Player).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ */
+com.miti99.netty.fbs.LoginResponse.startLoginResponse = function(builder) {
+ builder.startObject(1);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} playerOffset
+ */
+com.miti99.netty.fbs.LoginResponse.addPlayer = function(builder, playerOffset) {
+ builder.addFieldOffset(0, playerOffset, 0);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @returns {flatbuffers.Offset}
+ */
+com.miti99.netty.fbs.LoginResponse.endLoginResponse = function(builder) {
+ var offset = builder.endObject();
+ return offset;
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} playerOffset
+ * @returns {flatbuffers.Offset}
+ */
+com.miti99.netty.fbs.LoginResponse.createLoginResponse = function(builder, playerOffset) {
+ com.miti99.netty.fbs.LoginResponse.startLoginResponse(builder);
+ com.miti99.netty.fbs.LoginResponse.addPlayer(builder, playerOffset);
+ return com.miti99.netty.fbs.LoginResponse.endLoginResponse(builder);
+}
+
+/**
+ * @constructor
+ */
+com.miti99.netty.fbs.Packet = function() {
+ /**
+ * @type {flatbuffers.ByteBuffer}
+ */
+ this.bb = null;
+
+ /**
+ * @type {number}
+ */
+ this.bb_pos = 0;
+};
+
+/**
+ * @param {number} i
+ * @param {flatbuffers.ByteBuffer} bb
+ * @returns {com.miti99.netty.fbs.Packet}
+ */
+com.miti99.netty.fbs.Packet.prototype.__init = function(i, bb) {
+ this.bb_pos = i;
+ this.bb = bb;
+ return this;
+};
+
+/**
+ * @param {flatbuffers.ByteBuffer} bb
+ * @param {com.miti99.netty.fbs.Packet=} obj
+ * @returns {com.miti99.netty.fbs.Packet}
+ */
+com.miti99.netty.fbs.Packet.getRootAsPacket = function(bb, obj) {
+ return (obj || new com.miti99.netty.fbs.Packet).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+};
+
+/**
+ * @param {flatbuffers.ByteBuffer} bb
+ * @param {com.miti99.netty.fbs.Packet=} obj
+ * @returns {com.miti99.netty.fbs.Packet}
+ */
+com.miti99.netty.fbs.Packet.getSizePrefixedRootAsPacket = function(bb, obj) {
+ bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
+ return (obj || new com.miti99.netty.fbs.Packet).__init(bb.readInt32(bb.position()) + bb.position(), bb);
+};
+
+/**
+ * @returns {com.miti99.netty.fbs.PacketData}
+ */
+com.miti99.netty.fbs.Packet.prototype.dataType = function() {
+ var offset = this.bb.__offset(this.bb_pos, 4);
+ return offset ? /** @type {com.miti99.netty.fbs.PacketData} */ (this.bb.readUint8(this.bb_pos + offset)) : com.miti99.netty.fbs.PacketData.NONE;
+};
+
+/**
+ * @param {flatbuffers.Table} obj
+ * @returns {?flatbuffers.Table}
+ */
+com.miti99.netty.fbs.Packet.prototype.data = function(obj) {
+ var offset = this.bb.__offset(this.bb_pos, 6);
+ return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ */
+com.miti99.netty.fbs.Packet.startPacket = function(builder) {
+ builder.startObject(2);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {com.miti99.netty.fbs.PacketData} dataType
+ */
+com.miti99.netty.fbs.Packet.addDataType = function(builder, dataType) {
+ builder.addFieldInt8(0, dataType, com.miti99.netty.fbs.PacketData.NONE);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} dataOffset
+ */
+com.miti99.netty.fbs.Packet.addData = function(builder, dataOffset) {
+ builder.addFieldOffset(1, dataOffset, 0);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @returns {flatbuffers.Offset}
+ */
+com.miti99.netty.fbs.Packet.endPacket = function(builder) {
+ var offset = builder.endObject();
+ return offset;
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} offset
+ */
+com.miti99.netty.fbs.Packet.finishPacketBuffer = function(builder, offset) {
+ builder.finish(offset);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} offset
+ */
+com.miti99.netty.fbs.Packet.finishSizePrefixedPacketBuffer = function(builder, offset) {
+ builder.finish(offset, undefined, true);
+};
+
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {com.miti99.netty.fbs.PacketData} dataType
+ * @param {flatbuffers.Offset} dataOffset
+ * @returns {flatbuffers.Offset}
+ */
+com.miti99.netty.fbs.Packet.createPacket = function(builder, dataType, dataOffset) {
+ com.miti99.netty.fbs.Packet.startPacket(builder);
+ com.miti99.netty.fbs.Packet.addDataType(builder, dataType);
+ com.miti99.netty.fbs.Packet.addData(builder, dataOffset);
+ return com.miti99.netty.fbs.Packet.endPacket(builder);
+}
+
+// Exports for Node.js and RequireJS
+this.com = com;
diff --git a/netty/pom.xml b/netty/pom.xml
new file mode 100644
index 0000000..01e58ca
--- /dev/null
+++ b/netty/pom.xml
@@ -0,0 +1,61 @@
+
+
+
+ learn-netty
+
+
+
+ gson
+ com.google.code.gson
+ 2.10.1
+
+
+ logback-classic
+ ch.qos.logback
+ 1.4.6
+
+
+ flatbuffers-java
+ com.google.flatbuffers
+ 1.12.0
+
+
+ netty-all
+ io.netty
+ compile
+ 4.1.89.Final
+
+
+ junit-jupiter
+ org.junit.jupiter
+ test
+ 5.9.2
+
+
+ lombok
+ org.projectlombok
+ provided
+ 1.18.26
+
+
+
+ com.miti99
+ 4.0.0
+
+
+ server
+
+
+ pom
+
+
+ 17
+ 17
+ UTF-8
+
+
+ 1.0-SNAPSHOT
+
+
diff --git a/netty/server/pom.xml b/netty/server/pom.xml
index 8f19535..8d3b016 100644
--- a/netty/server/pom.xml
+++ b/netty/server/pom.xml
@@ -2,47 +2,17 @@
+
server
-
-
- logback-classic
- ch.qos.logback
- 1.4.5
-
-
- flatbuffers-java
- com.google.flatbuffers
- 1.12.0
-
-
- netty-all
- io.netty
- compile
- 4.1.89.Final
-
-
- junit-jupiter
- org.junit.jupiter
- test
- 5.9.2
-
-
- lombok
- org.projectlombok
- provided
- 1.18.26
-
-
- com.miti99
4.0.0
-
- 17
- 17
- UTF-8
-
+
+ com.miti99
+ learn-netty
+ 1.0-SNAPSHOT
+
- 1.0-SNAPSHOT
+ ${parent.version}
diff --git a/netty/server/src/main/java/MyGame/Sample/Color.java b/netty/server/src/main/java/MyGame/Sample/Color.java
deleted file mode 100644
index 18bce4c..0000000
--- a/netty/server/src/main/java/MyGame/Sample/Color.java
+++ /dev/null
@@ -1,15 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package MyGame.Sample;
-
-public final class Color {
- private Color() { }
- public static final byte Red = 0;
- public static final byte Green = 1;
- public static final byte Blue = 2;
-
- public static final String[] names = { "Red", "Green", "Blue", };
-
- public static String name(int e) { return names[e]; }
-}
-
diff --git a/netty/server/src/main/java/MyGame/Sample/Equipment.java b/netty/server/src/main/java/MyGame/Sample/Equipment.java
deleted file mode 100644
index 0618cae..0000000
--- a/netty/server/src/main/java/MyGame/Sample/Equipment.java
+++ /dev/null
@@ -1,14 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package MyGame.Sample;
-
-public final class Equipment {
- private Equipment() { }
- public static final byte NONE = 0;
- public static final byte Weapon = 1;
-
- public static final String[] names = { "NONE", "Weapon", };
-
- public static String name(int e) { return names[e]; }
-}
-
diff --git a/netty/server/src/main/java/MyGame/Sample/Monster.java b/netty/server/src/main/java/MyGame/Sample/Monster.java
deleted file mode 100644
index d71e79d..0000000
--- a/netty/server/src/main/java/MyGame/Sample/Monster.java
+++ /dev/null
@@ -1,76 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package MyGame.Sample;
-
-import java.nio.*;
-import java.lang.*;
-import java.util.*;
-import com.google.flatbuffers.*;
-
-@SuppressWarnings("unused")
-public final class Monster extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_1_12_0(); }
- public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
- public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public Monster __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public MyGame.Sample.Vec3 pos() { return pos(new MyGame.Sample.Vec3()); }
- public MyGame.Sample.Vec3 pos(MyGame.Sample.Vec3 obj) { int o = __offset(4); return o != 0 ? obj.__assign(o + bb_pos, bb) : null; }
- public short mana() { int o = __offset(6); return o != 0 ? bb.getShort(o + bb_pos) : 150; }
- public short hp() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) : 100; }
- public String name() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(10, 1); }
- public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 10, 1); }
- public int inventory(int j) { int o = __offset(14); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; }
- public int inventoryLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
- public ByteVector inventoryVector() { return inventoryVector(new ByteVector()); }
- public ByteVector inventoryVector(ByteVector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), bb) : null; }
- public ByteBuffer inventoryAsByteBuffer() { return __vector_as_bytebuffer(14, 1); }
- public ByteBuffer inventoryInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 14, 1); }
- public byte color() { int o = __offset(16); return o != 0 ? bb.get(o + bb_pos) : 2; }
- public MyGame.Sample.Weapon weapons(int j) { return weapons(new MyGame.Sample.Weapon(), j); }
- public MyGame.Sample.Weapon weapons(MyGame.Sample.Weapon obj, int j) { int o = __offset(18); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
- public int weaponsLength() { int o = __offset(18); return o != 0 ? __vector_len(o) : 0; }
- public MyGame.Sample.Weapon.Vector weaponsVector() { return weaponsVector(new MyGame.Sample.Weapon.Vector()); }
- public MyGame.Sample.Weapon.Vector weaponsVector(MyGame.Sample.Weapon.Vector obj) { int o = __offset(18); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
- public byte equippedType() { int o = __offset(20); return o != 0 ? bb.get(o + bb_pos) : 0; }
- public Table equipped(Table obj) { int o = __offset(22); return o != 0 ? __union(obj, o + bb_pos) : null; }
- public MyGame.Sample.Vec3 path(int j) { return path(new MyGame.Sample.Vec3(), j); }
- public MyGame.Sample.Vec3 path(MyGame.Sample.Vec3 obj, int j) { int o = __offset(24); return o != 0 ? obj.__assign(__vector(o) + j * 12, bb) : null; }
- public int pathLength() { int o = __offset(24); return o != 0 ? __vector_len(o) : 0; }
- public MyGame.Sample.Vec3.Vector pathVector() { return pathVector(new MyGame.Sample.Vec3.Vector()); }
- public MyGame.Sample.Vec3.Vector pathVector(MyGame.Sample.Vec3.Vector obj) { int o = __offset(24); return o != 0 ? obj.__assign(__vector(o), 12, bb) : null; }
-
- public static void startMonster(FlatBufferBuilder builder) { builder.startTable(11); }
- public static void addPos(FlatBufferBuilder builder, int posOffset) { builder.addStruct(0, posOffset, 0); }
- public static void addMana(FlatBufferBuilder builder, short mana) { builder.addShort(1, mana, 150); }
- public static void addHp(FlatBufferBuilder builder, short hp) { builder.addShort(2, hp, 100); }
- public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(3, nameOffset, 0); }
- public static void addInventory(FlatBufferBuilder builder, int inventoryOffset) { builder.addOffset(5, inventoryOffset, 0); }
- public static int createInventoryVector(FlatBufferBuilder builder, byte[] data) { return builder.createByteVector(data); }
- public static int createInventoryVector(FlatBufferBuilder builder, ByteBuffer data) { return builder.createByteVector(data); }
- public static void startInventoryVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); }
- public static void addColor(FlatBufferBuilder builder, byte color) { builder.addByte(6, color, 2); }
- public static void addWeapons(FlatBufferBuilder builder, int weaponsOffset) { builder.addOffset(7, weaponsOffset, 0); }
- public static int createWeaponsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
- public static void startWeaponsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
- public static void addEquippedType(FlatBufferBuilder builder, byte equippedType) { builder.addByte(8, equippedType, 0); }
- public static void addEquipped(FlatBufferBuilder builder, int equippedOffset) { builder.addOffset(9, equippedOffset, 0); }
- public static void addPath(FlatBufferBuilder builder, int pathOffset) { builder.addOffset(10, pathOffset, 0); }
- public static void startPathVector(FlatBufferBuilder builder, int numElems) { builder.startVector(12, numElems, 4); }
- public static int endMonster(FlatBufferBuilder builder) {
- int o = builder.endTable();
- return o;
- }
- public static void finishMonsterBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset); }
- public static void finishSizePrefixedMonsterBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset); }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public Monster get(int j) { return get(new Monster(), j); }
- public Monster get(Monster obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- }
-}
-
diff --git a/netty/server/src/main/java/MyGame/Sample/Vec3.java b/netty/server/src/main/java/MyGame/Sample/Vec3.java
deleted file mode 100644
index 2673c01..0000000
--- a/netty/server/src/main/java/MyGame/Sample/Vec3.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package MyGame.Sample;
-
-import java.nio.*;
-import java.lang.*;
-import java.util.*;
-import com.google.flatbuffers.*;
-
-@SuppressWarnings("unused")
-public final class Vec3 extends Struct {
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public Vec3 __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public float x() { return bb.getFloat(bb_pos + 0); }
- public float y() { return bb.getFloat(bb_pos + 4); }
- public float z() { return bb.getFloat(bb_pos + 8); }
-
- public static int createVec3(FlatBufferBuilder builder, float x, float y, float z) {
- builder.prep(4, 12);
- builder.putFloat(z);
- builder.putFloat(y);
- builder.putFloat(x);
- return builder.offset();
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public Vec3 get(int j) { return get(new Vec3(), j); }
- public Vec3 get(Vec3 obj, int j) { return obj.__assign(__element(j), bb); }
- }
-}
-
diff --git a/netty/server/src/main/java/MyGame/Sample/Weapon.java b/netty/server/src/main/java/MyGame/Sample/Weapon.java
deleted file mode 100644
index 8401f2a..0000000
--- a/netty/server/src/main/java/MyGame/Sample/Weapon.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// automatically generated by the FlatBuffers compiler, do not modify
-
-package MyGame.Sample;
-
-import java.nio.*;
-import java.lang.*;
-import java.util.*;
-import com.google.flatbuffers.*;
-
-@SuppressWarnings("unused")
-public final class Weapon extends Table {
- public static void ValidateVersion() { Constants.FLATBUFFERS_1_12_0(); }
- public static Weapon getRootAsWeapon(ByteBuffer _bb) { return getRootAsWeapon(_bb, new Weapon()); }
- public static Weapon getRootAsWeapon(ByteBuffer _bb, Weapon obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
- public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
- public Weapon __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
-
- public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
- public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
- public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
- public short damage() { int o = __offset(6); return o != 0 ? bb.getShort(o + bb_pos) : 0; }
-
- public static int createWeapon(FlatBufferBuilder builder,
- int nameOffset,
- short damage) {
- builder.startTable(2);
- Weapon.addName(builder, nameOffset);
- Weapon.addDamage(builder, damage);
- return Weapon.endWeapon(builder);
- }
-
- public static void startWeapon(FlatBufferBuilder builder) { builder.startTable(2); }
- public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(0, nameOffset, 0); }
- public static void addDamage(FlatBufferBuilder builder, short damage) { builder.addShort(1, damage, 0); }
- public static int endWeapon(FlatBufferBuilder builder) {
- int o = builder.endTable();
- return o;
- }
-
- public static final class Vector extends BaseVector {
- public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
-
- public Weapon get(int j) { return get(new Weapon(), j); }
- public Weapon get(Weapon obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
- }
-}
-
diff --git a/netty/server/src/main/java/com/miti99/netty/Main.java b/netty/server/src/main/java/com/miti99/netty/Main.java
index bd70c7d..340373c 100644
--- a/netty/server/src/main/java/com/miti99/netty/Main.java
+++ b/netty/server/src/main/java/com/miti99/netty/Main.java
@@ -27,29 +27,33 @@ public class Main {
var childGroup = Epoll.isAvailable() ? new EpollEventLoopGroup() : new NioEventLoopGroup();
val serverBootstrap = new ServerBootstrap();
- serverBootstrap.group(parentGroup, childGroup).channel(
- NioServerSocketChannel.class
- ).handler(new LoggingHandler(LogLevel.DEBUG))
- .childHandler(new ChannelInitializer<>() {
-
- @Override
- protected void initChannel(Channel channel) {
- channel.pipeline()
- .addLast(new LoggingHandler(LogLevel.DEBUG))
- .addLast(new HttpServerCodec())
- .addLast(new HttpObjectAggregator(65536))
- .addLast(new WebSocketServerCompressionHandler())
- .addLast(new WebSocketServerProtocolHandler("/fbs", null, true))
- .addLast(new WebsocketDecoder())
- .addLast(new WebsocketHandler());
- }
- })
+ serverBootstrap
+ .group(parentGroup, childGroup)
+ .channel(NioServerSocketChannel.class)
+ .handler(new LoggingHandler(LogLevel.DEBUG))
.childHandler(
new ChannelInitializer<>() {
@Override
protected void initChannel(Channel channel) {
- channel.pipeline()
+ channel
+ .pipeline()
+ .addLast(new LoggingHandler(LogLevel.DEBUG))
+ .addLast(new HttpServerCodec())
+ .addLast(new HttpObjectAggregator(65536))
+ .addLast(new WebSocketServerCompressionHandler())
+ .addLast(new WebSocketServerProtocolHandler("/fbs", null, true))
+ .addLast(new WebsocketDecoder())
+ .addLast(new WebsocketHandler());
+ }
+ })
+ .childHandler(
+ new ChannelInitializer<>() {
+
+ @Override
+ protected void initChannel(Channel channel) {
+ channel
+ .pipeline()
.addLast(new LoggingHandler(LogLevel.INFO))
.addLast(new HttpServerCodec())
.addLast(new HttpObjectAggregator(65536))
@@ -57,8 +61,7 @@ public class Main {
.addLast(new WebSocketServerProtocolHandler("/json", null, true))
.addLast(new WebsocketHandler());
}
- }
- );
+ });
try {
val channelFuture = serverBootstrap.bind(1202).sync();
diff --git a/netty/server/src/main/java/com/miti99/netty/NetworkUtil.java b/netty/server/src/main/java/com/miti99/netty/NetworkUtil.java
new file mode 100644
index 0000000..1d203c0
--- /dev/null
+++ b/netty/server/src/main/java/com/miti99/netty/NetworkUtil.java
@@ -0,0 +1,24 @@
+package com.miti99.netty;
+
+import com.miti99.netty.json.response.BaseJsonResponse;
+import io.netty.channel.Channel;
+import java.nio.ByteBuffer;
+
+public class NetworkUtil {
+
+ public static void sendJsonResponse(Channel channel, BaseJsonResponse response) {
+ sendTextResponse(channel, response.toJson());
+ }
+
+ public static void sendTextResponse(Channel channel, String response) {
+ channel.writeAndFlush(response);
+ }
+
+ public static void sendBinaryResponse(Channel channel, ByteBuffer byteBuffer) {
+ channel.writeAndFlush(byteBuffer);
+ }
+
+ public static void sendBinaryResponse(Channel channel, byte[] bytes) {
+ channel.writeAndFlush(bytes);
+ }
+}
diff --git a/netty/server/src/main/java/com/miti99/netty/WebsocketDecoder.java b/netty/server/src/main/java/com/miti99/netty/WebsocketDecoder.java
index b8c9ebf..4da63f3 100644
--- a/netty/server/src/main/java/com/miti99/netty/WebsocketDecoder.java
+++ b/netty/server/src/main/java/com/miti99/netty/WebsocketDecoder.java
@@ -1,6 +1,6 @@
package com.miti99.netty;
-import MyGame.Sample.Monster;
+import com.miti99.netty.fbs.Packet;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
@@ -14,8 +14,10 @@ import lombok.extern.slf4j.Slf4j;
public class WebsocketDecoder extends MessageToMessageDecoder {
@Override
- protected void decode(ChannelHandlerContext channelHandlerContext,
- BinaryWebSocketFrame binaryWebSocketFrame, List