{"id":"coatmol/bytenet-max","name":"bytenet-max","scope":"coatmol","platform":"roblox","description":"Mirrored from the Wally registry.","version":"0.1.9","latest":"0.1.9","versions":["0.1.9"],"license":"MIT","licenseRating":"safe","licenseCaveats":["License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{},"integrity":"49f5478da522150cb60aec3542d799b2c10d1f47bfe7a3017e5d2f6957d78a43","likes":0,"downloads":0,"install":"forest install coatmol/bytenet-max","url":"https://forest.dev/p/roblox/coatmol/bytenet-max","files":"https://api.forest.dev/ai/package/roblox/coatmol/bytenet-max/files","readme":"<div align=\"center\"><h1><b>ByteNet Max</b></h1></div>\n<div align=\"center\"><h2><b>An upgraded buffer-based networking system</b></h2></div>\n<div align=\"center\"><a href=\"https://github.com/Elitriare/ByteNet-Max\">GitHub</a> | <a href=\"https://wally.run/package/elitriare/bytenet-max?version=0.1.8\">Wally</a> | <a href=\"https://create.roblox.com/store/asset/81428213632345/ByteNet-Max\">Roblox Creator Store</a></div>\n\nByteNet Max is an upgraded version of @ffrostfall's [ByteNet](https://devforum.roblox.com/t/bytenet-advanced-networking-library-w-buffer-serialization-strict-luau-absurd-optimization-and-rbxts-support-043/2733365) which relies on strict type-checking to serialise your data into buffers before deserialising it on the other end, feeding it back to your Luau code. But what makes ByteNet Max different from ByteNet? ByteNet Max supports queries (RemoteFunctions) which are client to server requests for data. This brings you an extremely optimised experience for RemoteFunctions, using minimal data to increase send and receive speeds. ByteNet Max lives up to ByteNet's idea of making networking simple, easy and quick. The API is simple and minimalistic, helping you grasp the concepts of ByteNet Max pretty quickly!\n\n<h3><b>Installation</b></h3> \n\nGet [ByteNet Max](https://create.roblox.com/store/asset/81428213632345/ByteNet-Max) on the Roblox Creator Store, or on [Wally](https://wally.run/package/elitriare/bytenet-max?version=0.1.8) **(WARNING: v1.0.0 is the FIRST version of ByteNet Max, due to an error I made. The latest version is always the one shown on the title of this post)**!\n\n<h3><b>Performance</b></h3> \n\nByteNet Max lives up to the standards of ByteNet, performing incredibly well compared to other networking libraries such as BridgeNet2. The conversion to a buffer reduces memory usage significantly, helping optimise and speed up data transfer.\n\n<h3><b>Documentation</b></h3> \n\nByteNet Max follows the same architecture as ByteNet, hence the documentation for RemoteEvents (packets) is the exact same and can be found here: [Documentation](https://ffrostfall.github.io/ByteNet/api/functions/definePacket/).\n\nHowever, it adds a new system named **queries**. This is the ByteNet equivalent of a RemoteFunction. To begin, you can create a ModuleScript to define a namespace under which your packets and queries will be held:\n```lua\nlocal ByteNetMax = require(path.to.ByteNetMax)\n\nreturn ByteNetMax.defineNamespace(\"PlayerData\", function()\n    return {\n       packets = {}, -- not necessary to include this table if there's no values in it.\n       queries = {\n\t\t\tGetCoins = ByteNetMax.defineQuery({\n\t\t\t\trequest = ByteNetMax.struct({\n\t\t\t\t\tmessage = ByteNetMax.string\n\t\t\t\t}),\n\t\t\t\tresponse = ByteNetMax.struct({\n\t\t\t\t\tcoins = ByteNetMax.uint8\n\t\t\t\t})\n\t\t\t})\n\t\t},\t\t\n    }\nend)\n```\n\nThen, in a local script, you can invoke the query like so:\n```lua\nlocal QueryModule = require(path.to.QueryModule)\n\nlocal Coins = QueryModule.queries.GetCoins.invoke({\n\tmessage = \"Can I please get the coins value?\"\n})\n\nprint(Coins)\n```\n\nIn a server script, you can receive the query and return the appropriate information, like so:\n```lua\nlocal QueryModule = require(path.to.QueryModule)\n\nQueryModule.queries.GetCoins.listen(function(data, player)\t\n    print(data.message) -- prints \"Can I please get the coins value?\"\n\treturn {coins = player.leaderstats.Coins.Value}\nend)\n```\n\nIf you want to disconnect the listener in the future, you can assign the function to a variable:\n```lua\nlocal QueryModule = require(path.to.QueryModule)\nlocal Listener \n\nListener = QueryModule.queries.GetCoins.listen(function(data, player)\t\n    print(data.message) -- prints \"Can I please get the coins value?\"\n\treturn {coins = player.leaderstats.Coins.Value}\nend)\n\nListener() -- disconnects listener\n```\n\nThe above function works with **packets** too!\n\nIt's that simple!\n\nPackets & Queries can co-exist under the same namespace, just make sure you define the packets and queries table in defineNamespace. If you don't require packets, you can leave it out and just define the queries table, and vice versa.\n\n<b>IMPORTANT:</b> <u><b><i>You must require the ModuleScript you created on both the server and client! This is to initialise server side & client side dependencies for a secure network.</b></i></u>\n\n<h2>Some extra functions</h2>\n\nByteNet Max also adds extra functions for both packets & queries for better control over your code. You can now use .listenOnce() and .disconnectAll() to call a function once or disable all callbacks connected to a packet/query (equivalent to the :Disconnect() and :Once() functions from Roblox)\n\nUsing the example above, .listenOnce() is used the same way as .listen() : \n```lua\nlocal QueryModule = require(path.to.QueryModule)\n\nQueryModule.queries.GetCoins.listenOnce(function(data, player)\t -- this callback only runs once, before disconnecting.\n    print(data.message) -- prints \"Can I please get the coins value?\"\n\treturn {coins = player.leaderstats.Coins.Value}\nend)\n```\n\nThe .disconnectAll() function can be used to completely erase every callback created through .listen():\n```lua\nlocal QueryModule = require(path.to.QueryModule)\n\nQueryModule.queries.GetCoins.disconnectAll() -- disconnects all callbacks\n```\n\n<h3><b>Contact</b></h3> \n\nContact me on [Twitter](https://x.com/Elitriare) or Discord (username: elitriare), or just on this thread to report bugs or request features. I haven't fully tested this across different types of experiences, so your ***feedback*** is extremely useful!\n\nThis project is open-source.\n","readmeTruncated":false}