Coder Social home page Coder Social logo

csmh's Introduction

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:

The CMH 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:

Client:

RegisterServerResponses(config table)

  • RegisterServerResponses takes a config table (see Both section for structure) and registers functionId's to corresponding client side functions. You then use these functionId's in SendServerResponse.

SendClientRequest(prefix, functionId, ...)

  • SendClientRequest sends a Client Request to the Server, with prefix and functionId defined in your server config table. Takes any amount of string, integer, table or boolean variables and sends to the corresponding function.

Server:

RegisterClientRequests(config table)

  • RegisterClientRequests takes a config table (see Both section for structure) and registers functionId's to corresponding server side functions. You then use these functionId's in SendClientRequest.

Player:SendServerResponse(prefix, functionId, ...)

  • SendServerResponse sends a Server Response to the Client, with prefix and functionId defined in your client config table. Takes any amount of string, integer, table or boolean variables and sends to the corresponding function. Requires player object.

Both:

local config = {
	Prefix = "YourAddonName",
	Functions = {
		[1] = "YourFunctionName",
		[2] = "YourOtherFunctionName",
		[n] = "..."
	}
}
  • The config table is required for any script using CSMH, both client and server side. Using the same Prefix on client and server is not required, but recommended for ease of use. You can register any amount of functions in the Functions section of the config table.

Credits:

csmh's People

Contributors

foereaper avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.