Unofficial World of Warcraft Forums  
Please respect other members. Please do not post links or information about hacking/warez/cheats.
Read the rules of these forums as we rarely warn before banning. Lost or need RSS check the forum map.

Quick Site Nav
Navigation
Worldofwar.Net
WoW Forums
WoWDigger WoW Database
Articles
Community Blogs
WoW Info
Wrath of the Lich King Info
Primary Professions
Secondary Professions
Maps
Classes
PvP
A-Z Index
Guides
Submit Guides
List Guides
UI/Mods
Latest Mods
Submit Mod
List Macros
Submit Macro
Media Gallery
Gallery Home
Upload Pics
Community WoW Shots
Community BC Shots
Player Pics
Official WoW Shots
Official BC Shots


Donate and get extra forum perks
Support WoW:IncGamers

Go Back   Unofficial World of Warcraft Forums > WoW Community Forums > UI Customisation > UI/Mod Developer Forum

Reply
 
Thread Tools Display Modes
Old 30-06-2006, 12:18 PM   #1
Positronics
WorldofWar.Net Member
 
Join Date: Jun 2006
Posts: 3
Framework for Synchronization Communication

I have been working on a raid loot distribution and DKP management mod for a while. Apparently the mod utilises the chat channel extensively for communication between the raid members and the loot master.

During the course of development, I turned out to have spent quite some time creating a reusable framework for synchronization through a single channel.

I thought that after all this time spent the framework become quite easy now to implement in virtually any new mods which require syncing through a channel. The mod dev can just define the sync command and create the handling function, without having to worry about the communication bit.

Features of this framework include:
- Basic XOR encryption of all string sent to prevent casual spoofing.
- Large string transmission (yes, it does transmit strings longer than the 255-char limit) This is done by automatic separation of the string into "chunks" of 245 characters, each chunk with an identification header.
- Unique key for each set of string. This is to verify integrity of data especially when the response is specified to a particular request, and also to verify that all data chunks are received before re-merging.
- Easy definition of new sync commands. This is simply a matter of mapping the command word of choice to the name of the function which handles the command. (eg. TblCommands["NEWCMD"]="HandlingFunction_1" will redirect all chat message with command "NEWCMD" to function "HandlingFunction_1" for processing, etc.)


As shown here, the addon transmits long string, encoded in hex XOR'd format. The header "nj4ma/1" sets the command's unique key to nj4ma and /1 tells the client that this is the first chunk, likewise "nj4ma/2" tells the addon that it's the second chunk. Notice the last chunk is indicated by a semicolon at its end. The addon reads through chunk#1 through to the number ending with semicolon of the same key to find any nil value (which means missing chunk, and it will request the missing one again), and if none it will combine them together and de-XOR into the original command. (Commands are input as table of parameters which is automatically parsed into one-line text)

I don't know whether anyone else has done something like this before or not, but if you guys think this will be useful in your development then I am willing to publish the communication bit alone for reuse (mainly because I think the hours I spent on the communication bit shouldn't be wasted entirely into my humble DKP mod). But if no one will use it then I won't bother, you guys say it.

Last edited by Positronics; 30-06-2006 at 12:25 PM..
Positronics is offline   Reply With Quote
Old 30-06-2006, 12:40 PM   #2
Positronics
WorldofWar.Net Member
 
Join Date: Jun 2006
Posts: 3
Just in case you don't get what I meant exactly, here's some simple working example:

Suppose your mod needs to send the user's current target name, its %hp, and its class to everyone in the same sync channel. All you have to do are:

Step 1: Define your command. To do this, map the keyword you want to use to identify your command to the function you create to handle it. Do this just like when you define a global variable outside a function.

Code:
CommMod_Command["TARGETINFO"]="MyMod_ProcessTarget";
Step 2: Create the handler. Your handler should be in the format of:
Code:
function MyMod_ProcessTarget(from,data)
     DEFAULT_CHAT_FRAME:AddMessage(from.." targets "..data["param"]["name"].." processing now!");
     <your procedures, process the info, etc, blah blah blah>
end
Where "from" is the character name who sent the data, and "data" is the table of the following format:
Code:
data = {
     ["cmd"]="TARGETINFO",
     ["key"]=<unique key>,
     ["param"]={
          ["name"]="Ragnaros",
          ["hp"]=36,
          ["class"]="Warrior"
     }
}
Which can readily be used without any further manipulation. Of course, the number of parameters within ["param"] can be of any number of your choice.

Step 3: Create a function to send the data. This is simple, just create a table of the same format said before (without the key, which is generated automatically upon transmission), then pass the table to the send function in the communication mod.

Code:
function SendTargetInfo()
     myTable["cmd"]="TARGETINFO";
     myTable["param"]["name"]=UnitName("target");
     <add more parameters and values, blah blah blah>
     
     CommMod_TransmitTable(myTable);
end
The channel used is set through the communication mod so you don't have to worry about it. You don't even have to hook the CHAT_MSG_CHANNEL event since it's all done through the framework.
------------------------
Hope you get the idea of what I'm on about here. Shoot feedback away.

Last edited by Positronics; 30-06-2006 at 12:47 PM..
Positronics is offline   Reply With Quote
Old 12-07-2006, 10:16 PM   #3
Voista
WorldofWar.Net Member
 
Join Date: Jul 2006
Location: Miami, FL
Posts: 2
Very very nice work.
Voista is offline   Reply With Quote
Old 14-07-2006, 08:08 AM   #4
Voista
WorldofWar.Net Member
 
Join Date: Jul 2006
Location: Miami, FL
Posts: 2
Shot you a private message. Please reply.. would love to check out/admire your hard work.
Voista is offline   Reply With Quote
Old 14-07-2006, 10:29 AM   #5
Zeraph
WorldofWar.Net Member
 
Join Date: Jun 2006
Location: Central, USA
Posts: 15
Oh wow, this looks really really useful!
Please do post it, I might want to use this some time in a mod, I do not know what for exactly yet, but I know it's going to come in handy sometime. maybe you could make it into a kind of "dependency only" mod?
Zeraph is offline   Reply With Quote
Old 16-07-2006, 10:21 PM   #6
Blackal
WorldofWar.Net Member
 
Join Date: Jul 2006
Posts: 11
I sent you a PM as well. I would love to see this mod and integrate it into a mod I am working on!

Thanks!
Blackal is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:18 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Advertisement System V2.5 By   Branden