From 2539da56772a039604d6f598d8acdc7bc6ba6272 Mon Sep 17 00:00:00 2001 From: Foereaper Date: Fri, 16 Jul 2021 01:09:54 +0200 Subject: [PATCH] Remove unnecessary automated backup files --- README.md.bak | 50 ---------------- Server/SMH.lua.bak | 144 --------------------------------------------- 2 files changed, 194 deletions(-) delete mode 100644 README.md.bak delete mode 100644 Server/SMH.lua.bak diff --git a/README.md.bak b/README.md.bak deleted file mode 100644 index b351b4b..0000000 --- a/README.md.bak +++ /dev/null @@ -1,50 +0,0 @@ -# CSMH - -### What is CSMH? -CSMH is a Client and Server Message Handler framework for communication between Eluna and the WoW interface. It has been tested on Mangos and TrinityCore 3.3.5a, but it will probably work for other versions as well. - -CSMH consists of two parts, the Client Message Handler and the Server Message Handler respectively. - -### How does this compare to AIO? -While AIO is the most used solution of this kind, it has its drawbacks as well. While it allows you to write all your code server-side, it also limits you to the Lua API only. AIO also sends the full addon code to the client on startup and reload, which is fairly network intensive. Upside of AIO is its ease of distribution compared to dedicated client-side addons. - -CSMH is only meant to transport data between the client and the server, and is therefore not as network intensive as AIO. You write your server-side code on the server, and you distribute your client-side code either as an addon, or in a patch. This allows you to use XML and templates, as well as the full Lua API. - -Both AIO and CSMH uses smallfolk for serialization, and is compatible with each other. You can use both AIO and CSMH in the same project. - -### What does CSMH do and *not* do? -CSMH intentionally does not do certain things, primarily for ease of integration and personal preferences around implementations like; Flood protection, data validation, packet filtering etc. - -CSMH **does** verify the sender and recipient of a message, to prevent messages being sent and accepted on someone else's behalf. - -CSMH **does not** natively check and verify what is being sent to and from the client and server. It is up to you to sanity check data being sent back and forth. A good rule of thumb is to never inherently trust data being sent to the server from the client, you need to verify data before accepting it. - -CSMH also **does not** have any form of built in flood protection. This is again up to you to decide on an implementation of your choice. - -### How do I use CSMH? -I would recommend going through the examples provided in this repo to get a feel for how registering, sending and receiving data on both the client and the server works. A full API and how-to will be posted soon™. - -## Installation: - -### Server: -- Copy everything from the Server directory to your Eluna scripts directory. That's it! - -### Client: -CSMH can be distributed either as a stand-alone addon, or through a patch. Files are provided for both solutions in the Client directory, but be aware of the differences: - -#### Addon: -- Copy **CMH.Lua**, **CMH.toc** and **smallfolk.lua** to **Interface\AddOns\CMH** - -#### MPQ Patch: -- Copy **CMH.Lua**, **FrameXML.toc** and **smallfolk.lua** to **Interface\FrameXML** - -## API: -Soon™ - -## Credits: -- [Stoneharry](https://github.com/stoneharry) -- [Terrorblade](https://github.com/Terrorblade) -- Kaev -- [Rochet / AIO](https://github.com/Rochet2) -- [Eluna](https://github.com/ElunaLuaEngine/Eluna) -- [smallfolk](https://github.com/gvx/Smallfolk) \ No newline at end of file diff --git a/Server/SMH.lua.bak b/Server/SMH.lua.bak deleted file mode 100644 index 8476d26..0000000 --- a/Server/SMH.lua.bak +++ /dev/null @@ -1,144 +0,0 @@ -local smallfolk = smallfolk or require("smallfolk") -local SMH = {} -local links = {} - -function SMH.OnReceive(event, sender, _type, prefix, _, target) - if not sender or not target or not sender.GetName or not target.GetName or type(sender) ~= "userdata" or type(target) ~= "userdata" then - return - end - if sender:GetName() == target:GetName() and _type == 7 then - local source, functionId, link, linkCount, MSG = prefix:match("(%D)(%d%d%d)(%d%d)(%d%d)(.+)"); - if not source or not functionId or not link or not linkCount or not MSG then - return - end - if(source == "C") then - functionId, link, linkCount = tonumber(functionId), tonumber(link), tonumber(linkCount); - - links[sender:GetGUIDLow()] = links[sender:GetGUIDLow()] or {} - links[sender:GetGUIDLow()][functionId] = links[sender:GetGUIDLow()][functionId] or {count = 0}; - links[sender:GetGUIDLow()][functionId][link] = MSG; - links[sender:GetGUIDLow()][functionId].count = links[sender:GetGUIDLow()][functionId].count + 1; - if (links[sender:GetGUIDLow()][functionId].count ~= linkCount) then - return - end - - local fullMessage = table.concat(links[sender:GetGUIDLow()][functionId]); - links[sender:GetGUIDLow()][functionId] = {count = 0}; - - local VarTable = ParseMessage(fullMessage) - if not VarTable then - return - end - if not(SMH[VarTable[1]]) then - return - end - - local func = SMH[VarTable[1]][functionId] - if func then - _G[func](sender, VarTable) - end - return - end - end -end - -RegisterServerEvent(30, SMH.OnReceive) - -function RegisterClientRequests(config) - -- If a config table with the Prefix already exists, abort loading it into the register. - if(SMH[config.Prefix]) then - return; - end - - -- Create subtable for PrefixName - SMH[config.Prefix] = {} - - -- Insert function ID and function name into the register table. - for functionId, functionName in pairs(config.Functions) do - SMH[config.Prefix][functionId] = functionName - end -end - -function ParseMessage(str) - local output = {} - local valTemp = {} - local typeTemp = {} - local delim = {"♠", "♥", "♚", "♛", "♜"} - - local valMatch = "[^"..table.concat(delim).."]+" - local typeMatch = "["..table.concat(delim).."]+" - - -- Get values - for value in str:gmatch(valMatch) do - table.insert(valTemp, value) - end - - -- Get type from delimiter - for varType in str:gmatch(typeMatch) do - for k, v in pairs(delim) do - if(v == varType) then - table.insert(typeTemp, k) - end - end - end - - -- Convert value to correct type - for k, v in pairs(valTemp) do - local varType = typeTemp[k] - if(varType == 3) then -- Ints - v = tonumber(v) - elseif(varType == 4) then -- Tables - v = smallfolk.loads(v) - elseif(varType == 5) then -- Booleans - if(v == "true") then v = true else v = false end - end - table.insert(output, v) - end - - valTemp = nil - typeTemp = nil - - return output -end - -function Player:SendServerResponse(prefix, functionId, ...) - -- ♠ = Prefix prefix - -- ♥ = ArgumentPrefix for Strings - -- ♚ = ArgumentPrefix for Ints - -- ♛ = ArgumentPrefix for Tables - -- ♜ = ArgumentPrefix for Boolean - - local arg = {...} - local splitLength = 230 - local msg = "♠" .. prefix - - for _, v in pairs(arg) do - if(type(v) == "string") then - msg = msg .. "♥" - elseif(type(v) == "number") then - msg = msg .. "♚" - elseif(type(v) == "table") then - -- use Smallfolk to convert table structure to string - v = smallfolk.dumps(v) - msg = msg .. "♛" - elseif(type(v) == "boolean") then - v = tostring(v) - msg = msg .. "♜" - end - msg = msg .. v - end - - local splits = math.ceil(msg:len() / splitLength) - local send - local counter = 1 - for i=1, msg:len(), splitLength do - send = string.format("%01s%02d%03d%03d", "S", functionId, counter, splits) - if ((i + splitLength) > msg:len()) then - send = send .. msg:sub(i, msg:len()) - else - send = send .. msg:sub(i, i + splitLength - 1) - end - counter = counter + 1 - self:SendAddonMessage(send, "", 7, self) - end -end \ No newline at end of file