- All Implemented Interfaces:
AutoCloseable
MumbleLink
object serves as a view for the data provided by a Guild Wars 2 game client in MumbleLink
format. The data may either be provided by the game client via the MumbleLink mechanism or by a custom source. An
instance for the former can be obtained by calling open()
- the primary entry point of GW2ML.- Since:
- 0.1.0
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The size of the MumbleLink buffer in bytes. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the underlying buffer by setting all bytes to zero.void
close()
Closes this resource.void
copy
(byte[] dest) Shorthand forcopy(0, dest, 0, BYTES)
.void
copy
(int srcOffset, byte[] dest, int destOffset, int length) Copies the underlying data beginning at the specified offset, to the specified offset of the destination array.void
copy
(int srcOffset, MemorySegment dest, int destOffset, int length) Copies the underlying data beginning at the specified offset, to the specified offset of the destination buffer.void
copy
(int srcOffset, ByteBuffer dest, int destOffset, int length) Deprecated, for removal: This API element is subject to removal in a future version.void
copy
(MemorySegment dest) Shorthand forcopy(0, dest, 0, BYTES)
.void
copy
(ByteBuffer dest) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated in favor ofcopy(MemorySegment)
.float[]
getAvatarFront
(float[] dest) Returns the unit vector pointing out of the avatar's eyes.float[]
getAvatarPosition
(float[] dest) Returns the position of the avatar (in meters).float[]
getAvatarTop
(float[] dest) Returns the unit vector pointing out of the top of the avatar's head.float[]
getCameraFront
(float[] dest) Returns the unit vector pointing out of the camera.float[]
getCameraPosition
(float[] dest) Returns the position of the camera (in meters).float[]
getCameraTop
(float[] dest) Returns the unit vector pointing out of the top of the camera.Returns aContext
object that may be used to access the additional context information.long
Returns the length of the context (in bytes) that will be used by a MumbleServer to determine whether two users can hear each other positionally.Returns the description that may provide additional information about the game's current state.Returns a JSON-formattedString
with additional information.getName()
Returns the name of the application which updated the underlying data last.long
Returns an integral identifier that is incremented every time the MumbleLink data is updated.long
Returns the version number as specified by the MumbleLink standard.boolean
isClosed()
Returns whether this object is invalid.static MumbleLink
open()
Opens aMumbleLink
view of the data provided by Guild Wars 2 via the MumbleLink mechanism.static MumbleLink
Opens aMumbleLink
view of the data provided by Guild Wars 2 via the MumbleLink mechanism using a custom handle.static MumbleLink
viewOf
(MemorySegment segment) Returns aMumbleLink
view of the given memory segment.static MumbleLink
viewOf
(ByteBuffer buffer) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated in favor ofviewOf(MemorySegment)
.
-
Field Details
-
BYTES
public static final int BYTESThe size of the MumbleLink buffer in bytes.- Since:
- 0.1.0
-
-
Method Details
-
open
Opens aMumbleLink
view of the data provided by Guild Wars 2 via the MumbleLink mechanism.This method is shorthand for
MumbleLink.open("MumbleLink");
- Returns:
- a
MumbleLink
object that may be used to read the data provided by Guild Wars 2 via the MumbleLink mechanism - Throws:
IllegalStateException
- if an unexpected error occurs- Since:
- 0.1.0
- Implementation Note:
- For better performance, this implementation reuses native resources whenever possible. In practice, this means that closing a MumbleLink object might not immediately close the underlying native resources.
-
open
Opens aMumbleLink
view of the data provided by Guild Wars 2 via the MumbleLink mechanism using a custom handle.The object returned by this method must be explicitly
closed
.It is recommended to open a
MumbleLink
object once and keep it around for the lifetime of the application when possible.- Parameters:
handle
- the handle of the shared memory which will back the view- Returns:
- a
MumbleLink
object that may be used to read the data provided by Guild Wars 2 via the MumbleLink mechanism - Throws:
IllegalStateException
- if an unexpected error occurs- Since:
- 1.4.0
-
viewOf
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated in favor ofviewOf(MemorySegment)
.Returns aMumbleLink
view of the given buffer.The buffer must be a
direct
buffer.- Parameters:
buffer
- the buffer to provide aMumbleLink
view of- Returns:
- a
MumbleLink
object that may be used to read the data provided by the given buffer in the MumbleLink format - Throws:
IllegalArgumentException
- if the given buffer is not direct- Since:
- 1.3.0
-
viewOf
Returns aMumbleLink
view of the given memory segment.The segment must be aligned.
- Parameters:
segment
- the segment to provide aMumbleLink
view of- Returns:
- a
MumbleLink
object that may be used to read the data provided by the given segment in the MumbleLink format - Throws:
IllegalArgumentException
- if the given segment is not aligned- Since:
- 3.0.0
-
clear
public void clear()Clears the underlying buffer by setting all bytes to zero.- Since:
- 2.2.0
- API Note:
- It may be useful to clear a
MumbleLink
instance when launching multiple Guild Wars 2 processes with the same mumble handle sequentially.
-
close
public void close()Closes this resource.This method does nothing if this view is backed by a custom buffer or if it has already been closed.
- Specified by:
close
in interfaceAutoCloseable
- Since:
- 0.1.0
-
isClosed
public boolean isClosed()Returns whether this object is invalid.- Returns:
- whether this object is invalid
- Since:
- 0.1.0
- See Also:
-
copy
public void copy(byte[] dest) Shorthand forcopy(0, dest, 0, BYTES)
.- Parameters:
dest
- the destination array- Throws:
IllegalStateException
- if this view wasinvalidated
IndexOutOfBoundsException
- if any index is violatedNullPointerException
- ifdest
isnull
- Since:
- 1.3.0
-
copy
Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated in favor ofcopy(MemorySegment)
.Shorthand forcopy(0, dest, 0, BYTES)
.- Parameters:
dest
- the destination buffer- Throws:
IllegalStateException
- if this view wasinvalidated
IndexOutOfBoundsException
- if any index is violatedNullPointerException
- ifdest
isnull
- Since:
- 1.3.0
-
copy
Shorthand forcopy(0, dest, 0, BYTES)
.- Parameters:
dest
- the destination segment- Throws:
IllegalStateException
- if this view wasinvalidated
IndexOutOfBoundsException
- if any index is violatedNullPointerException
- ifdest
isnull
- Since:
- 3.0.0
-
copy
public void copy(int srcOffset, byte[] dest, int destOffset, int length) Copies the underlying data beginning at the specified offset, to the specified offset of the destination array.If any of the following is true, an IndexOutOfBoundsException is thrown and the destination is not modified:
- The
srcOffset
argument is negative. - The
destOffset
argument is negative. - The
length
argument is negative. srcOffset + length
is greater thanBYTES
, the length the MumbleLink bufferdestOffset + length
is greater thandest.length
, the length of the destination array.
- Parameters:
srcOffset
- starting position in the MumbleLink bufferdest
- the destination arraydestOffset
- starting position in the destination datalength
- the number of bytes to be copied- Throws:
IllegalStateException
- if this view wasinvalidated
IndexOutOfBoundsException
- if any index is violatedNullPointerException
- ifdest
isnull
- Since:
- 1.3.0
- The
-
copy
@Deprecated(since="3.0.0", forRemoval=true) public void copy(int srcOffset, ByteBuffer dest, int destOffset, int length) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated in favor ofcopy(int, MemorySegment, int, int)
.Copies the underlying data beginning at the specified offset, to the specified offset of the destination buffer.If any of the following is true, an IndexOutOfBoundsException is thrown and the destination is not modified:
- The
srcOffset
argument is negative. - The
destOffset
argument is negative. - The
length
argument is negative. srcOffset + length
is greater thanBYTES
, the length the MumbleLink bufferdestOffset + length
is greater thandest.length
, the length of the destination buffer.
- Parameters:
srcOffset
- starting position in the MumbleLink bufferdest
- the destination bufferdestOffset
- starting position in the destination datalength
- the number of bytes to be copied- Throws:
IllegalStateException
- if this view wasinvalidated
IndexOutOfBoundsException
- if any index is violatedNullPointerException
- ifdest
isnull
- Since:
- 1.3.0
- The
-
copy
Copies the underlying data beginning at the specified offset, to the specified offset of the destination buffer.If any of the following is true, an IndexOutOfBoundsException is thrown and the destination is not modified:
- The
srcOffset
argument is negative. - The
destOffset
argument is negative. - The
length
argument is negative. srcOffset + length
is greater thanBYTES
, the length the MumbleLink bufferdestOffset + length
is greater thandest.length
, the length of the destination buffer.
- Parameters:
srcOffset
- starting position in the MumbleLink bufferdest
- the destination bufferdestOffset
- starting position in the destination datalength
- the number of bytes to be copied- Throws:
IllegalStateException
- if this view wasinvalidated
IndexOutOfBoundsException
- if any index is violatedNullPointerException
- ifdest
isnull
- Since:
- 3.0.0
- The
-
getUIVersion
public long getUIVersion()Returns the version number as specified by the MumbleLink standard.This is part of the MumbleLink standard and useless to most applications.
- Returns:
- the version number as specified by the MumbleLink standard
- Throws:
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
-
getUITick
public long getUITick()Returns an integral identifier that is incremented every time the MumbleLink data is updated.Notes:
- At the time of writing MumbleLink data is not updated during loading screens. Thus, this identifier may be used to (roughly) detect whether game client is currently in one. (Keep in mind that is behavior might change.)
- Returns:
- an integral identifier that is incremented every time the MumbleLink data is updated
- Throws:
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
-
getAvatarPosition
public float[] getAvatarPosition(float[] dest) Returns the position of the avatar (in meters).Notes:
- Guild Wars 2's units correspond to inches.
- The coordinate system used by MumbleLink is left-handed.
- Due to limitations of the MumbleLink mechanism, it is possible that the underlying data is modified while reading, thus the returned position may be incorrect. (In practice, this is fairly rare and can just be ignored for the most part. Implement basic interpolation, if necessary.)
- Parameters:
dest
- the array to store the data in- Returns:
- the
dest
array - Throws:
IllegalArgumentException
- ifdest.length != 3
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
-
getAvatarFront
public float[] getAvatarFront(float[] dest) Returns the unit vector pointing out of the avatar's eyes.Notes:
- This is commonly referred to as "look-at-vector" in computer graphics.
- Parameters:
dest
- the array to store the data in- Returns:
- the
dest
array - Throws:
IllegalArgumentException
- ifdest.length != 3
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
-
getAvatarTop
public float[] getAvatarTop(float[] dest) Returns the unit vector pointing out of the top of the avatar's head.Notes:
- This is commonly referred to as "up-vector" in computer graphics.
- Parameters:
dest
- the array to store the data in- Returns:
- the
dest
array - Throws:
IllegalArgumentException
- ifdest.length != 3
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
-
getName
Returns the name of the application which updated the underlying data last.- Returns:
- the name of the application which updated the underlying data last
- Throws:
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
- API Note:
- In practice this should always be
"Guild Wars 2"
when the game client has focus and is the owner of the link data. It is common practice to use this value to check which application is currently writing to the MumbleLink data.
-
getCameraPosition
public float[] getCameraPosition(float[] dest) Returns the position of the camera (in meters).Notes:
- Guild Wars 2's units correspond to inches.
- The coordinate system used by MumbleLink is left-handed.
- Due to limitations of the MumbleLink mechanism, it is possible that the underlying data is modified while reading, thus the returned position may be incorrect. (In practice, this is fairly rare and can just be ignored for the most part. Implement basic interpolation, if necessary.)
- Parameters:
dest
- the array to store the data in- Returns:
- the
dest
array - Throws:
IllegalArgumentException
- ifdest.length != 3
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
-
getCameraFront
public float[] getCameraFront(float[] dest) Returns the unit vector pointing out of the camera.Notes:
- This is commonly referred to as "look-at-vector" in computer graphics.
- Parameters:
dest
- the array to store the data in- Returns:
- the
dest
array - Throws:
IllegalArgumentException
- ifdest.length != 3
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
-
getCameraTop
public float[] getCameraTop(float[] dest) Returns the unit vector pointing out of the top of the camera.Notes:
- This is commonly referred to as "up-vector" in computer graphics.
- Parameters:
dest
- the array to store the data in- Returns:
- the
dest
array - Throws:
IllegalArgumentException
- ifdest.length != 3
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
-
getIdentity
Returns a JSON-formattedString
with additional information.- Returns:
- a JSON-formatted
String
with additional information - Throws:
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
-
getContextLength
public long getContextLength()Returns the length of the context (in bytes) that will be used by a MumbleServer to determine whether two users can hear each other positionally.- Returns:
- the length of the context (in bytes) that will be used by a MumbleServer to determine whether two users can hear each other positionally
- Throws:
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
-
getContext
Returns aContext
object that may be used to access the additional context information.The returned object is strongly tied to this object and is only valid as long as this object is valid.
- Returns:
- a
Context
object that may be used to access the additional context information - Since:
- 0.1.0
-
getDescription
Returns the description that may provide additional information about the game's current state.- Returns:
- the description that may provide additional information about the game's current state
- Throws:
IllegalStateException
- if this view wasinvalidated
- Since:
- 0.1.0
- API Note:
- This field is currently not used by the game client.
-
copy(int, MemorySegment, int, int)
.