For Players
In order to follow ZOS' opt out policy (brought up in regards to Group Damage), LibGroupSocket gives you fine grained control over what data you share with your group. Per default it automatically disables the sending of all data when you leave a group, or quit the game.
You can download and install LibGroupSocket like any other addon, in order to enable saving settings for it.
Dependencies
The following dependencies are required by LibGroupSocket:
For Developers
LibGroupSocket offers a standardized way to share data with group members via map pings. It allows the sending of up to 3 byte of data in one ping or 7 bytes in 2 pings at a time.
Because the channel is very limited, there is currently only a maximum of 31 different message types supported.
If you are interested in adding a new message type, please contact me via pm and I will reserve an ID.
It is also encouraged to reuse existing message types and expand on them instead of adding a new one that does the same thing, but slightly different.
This first version of the library is mostly a trial to see how it will work in combination with the many other addons out there and also to see how ZOS will react and how much interest it generates with players.
For future versions I am considering to split message handlers into separate libraries, so they can be updated independently.
Known Issues- The library is currently not compatible with FTC's DPS sharing feature and you and all group members will see wrong values in FTC while LibGroupSocket is active
- User set group pings may cause incorrect data to show up in same rare cases
- User set group pings are overwritten when data is transmitted
- The compass may show the automatically set group pings
- Users without LibGroupSocket will see random group pings pop up in Wrothgar or Coldharbour
- Settings for LibGroupSocket won't be saved unless you use the stand alone version.
- Sometimes you may hear a sound when a ping is set
API Reference
ReadBit
Reads a bit from the data stream and increments the index and bit index accordingly.
Code:
boolean isSet, number nextIndex, number nextBitIndex = lib:ReadBit(table data, number index, number bitIndex)
data - an array of integers between 0 and 255
index - the current position to read from
bitIndex - the current bit inside the current byte (starts from 1)
Returns the state of the bit, the next position in the data array and the next bitIndex.
WriteBit
Writes a bit to the data stream and increments the index and bit index accordingly.
Code:
number nextIndex, number nextBitIndex = lib:WriteBit(table data, number index, number bitIndex, boolean value)
data - an array of integers between 0 and 255
index - the current position to write to
bitIndex - the current bit inside the current byte (starts from 1)
value - the new state of the bit
Returns the next position in the data array and the next bitIndex.
ReadChar
Reads a single byte from the data stream, converts it into a string character and increments the index accordingly.
Code:
string character, number nextIndex = lib:ReadChar(table data, number index)
data - an array of integers between 0 and 255
index - the current position to read from
Returns the character and the next position in the data array.
WriteChar
Writes a single character to the data stream and increments the index accordingly.
Code:
number nextIndex = lib:WriteChar(table data, number index, string value[, number charIndex])
data - an array of integers between 0 and 255
index - the current position to write to
value - a single character or a string of characters
charIndex - optional index of the character that should be written to the data stream. Defaults to the first character
Returns the next position in the data array.
ReadUint8
Reads a single byte from the data stream and increments the index accordingly.
Code:
number value, number nextIndex = lib:ReadUint8(table data, number index)
data - an array of integers between 0 and 255
index - the current position to read from
Returns the 8-bit unsigned integer and the next position in the data array.
WriteUint8
Writes an 8-bit unsigned integer to the data stream and increments the index accordingly. The value is clamped and floored to match the data type.
Code:
number nextIndex = lib:WriteUint8(table data, number index, string value)
data - an array of integers between 0 and 255
index - the current position to write to
value - an 8-bit unsigned integer
Returns the next position in the data array.
ReadUint16
Reads two byte from the data stream, converts them to one integer and increments the index accordingly.
Code:
number value, number nextIndex = lib:ReadUint16(table data, number index)
data - an array of integers between 0 and 255
index - the current position to read from
Returns the 16-bit unsigned integer and the next position in the data array.
WriteUint16
Writes a 16-bit unsigned integer to the data stream and increments the index accordingly. The value is clamped and floored to match the data type.
Code:
number nextIndex = lib:WriteUint16(table data, number index, string value)
data - an array of integers between 0 and 255
index - the current position to write to
value - a 16-bit unsigned integer
Returns the next position in the data array.
EncodeData
Converts 4 bytes of data into coordinates for a map ping.
Code:
number x, number y = lib:EncodeData(number b0, number b1, number b2, number b3, number stepSize)
b0 to b3 - integers between 0 and 255
Step size specifies the smallest possible increment for the coordinates on a map.
Returns normalized x and y coordinates.
DecodeData
Converts normalized map ping coordinates into 4 bytes of data.
Code:
number b0, number b1, number b2, number b3 = lib:DecodeData(number x, number y, number stepSize)
Step size specifies the smallest possible increment for the coordinates on a map.
Returns 4 integers between 0 and 255.
MessageType
MessageType is an enumeration of implemented message types.
lib.MESSAGE_TYPE_RESERVED: Reserved in case we ever have more than 31 message types. Can also be used for local tests.
lib.MESSAGE_TYPE_RESOURCES: For exchanging stamina and magicka values.
EncodeHeader
Packs a 5-bit messageType and a 3-bit length value into one byte of data.
Code:
number value = lib:EncodeHeader(MessageType messageType, number length)
messageType - integer between 0 and 31
length - integer between 0 and 7
Returns encoded header byte.
DecodeHeader
Unpacks a 5-bit messageType and a 3-bit length value from one byte of data.
Code:
MessageType messageType, number length = lib:DecodeHeader(number value)
value - integer between 0 and 255
Returns messageType and length.
Send
Queues up to seven byte of data of the selected messageType for broadcasting to all group members.
Code:
boolean isValid = lib:Send(MessageType messageType, table data)
messageType - the protocol that is used for encoding the sent data
data - up to 7 byte of custom data. if more than 3 bytes are passed, the data will take 2 map pins to arrive.
Returns true if the data was successfully queued. Data won't be queued when the general sending setting is off or an invalid value was passed.
RegisterHandler
Registers a handler module for a specific data type.
This module will keep everything related to data handling out of any single addon, in order to let multiple addons use the same messageType.
Code:
table handler, table saveData = lib:RegisterHandler(MessageType messageType, table data)
messageType - The messageType the handler will take care of
handlerVersion - The loaded handler version. Works like the minor version in LibStub and prevents older instances from overwriting a newer one
Returns the handler object and saveData for the messageType.
GetHandler
Gives access to an already registered handler for addons.
Code:
table handler = lib:GetHandler(MessageType messageType)
messageType - The messageType of the handler
Returns the handler object.
RegisterCallback
Register for unprocessed data of a messageType.
Code:
lib:RegisterCallback(MessageType messageType, function callback)
UnregisterCallback
Unregister for unprocessed data of a messageType.
Code:
lib:UnregisterCallback(MessageType messageType, function callback)
/lgs
Gives access to the "enabled" setting via a chat command.