Showing Posts For Lulan.8497:
Okay, i uploaded a new version. This time you will need to clear your java cache like described here: http://www.java.com/en/download/help/plugin_cache.xml
→ also check “installed applications and applets”
gn8
Hey,
at the moment the test programm uses the mumblelink module. since mumblelink requires memory mapped files (realised using jna, which requires windows os.) the sample application requires windows os.
I tried to run the sample application on my own windows system and it turned out, that the changes/updates planned for this ticket are required to get it run again: https://bitbucket.org/Lul4n/yagw2api/issue/1/include-wvw-changes
=> well, i did some basic implementation. the sample app is working again and i’m going to deploy a new jnlp version in the next few minutes (takes some time to upload xD)
Hey guys,
i decided to make my code open source und apache v2 licence.
You can get it from https://bitbucket.org/Lul4n/yagw2api/
YAGW2API (Yet Another GW2 API) provides simple integration for MumbleLink, Anet WVW API, GW2Stats API etc. in Java. It can be built using Maven and comes with an TTS (Text to Speech) sample application that uses another google API to tell you by voice whats going on in WVW. By now it supports english, french, german and spanish language.
Feel free to open issues if you run into any problem
At last: There is a reason, why I made my project public to find other java programmers that are interested to support me developing it much faster that i could do by my own. If you are interested, just contact me and i’ll share more information with you
greez Lul4n
(edited by Lulan.8497)
nice work!
how about a restful api to allow other programmers to provide clients/viewer?
Okay nice As it finally works now im very grateful for your support! I think i will integrate it into my yagw2api project and publish it in the near future. if any one is interested in it before, just contact me
PAGE_EXECUTE_READWRITE worked out
The problem with open is that the platform component of JNA does not provide the OpenFileMapping method…
Thank you for your answers
I put those correction into again a short example… well the result is still…. a bunch of zeros…
Is it possible, that i ran into some permission/security issues?
import java.util.Arrays;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.WinBase;
import com.sun.jna.platform.win32.WinNT;
import com.sun.jna.platform.win32.WinNT.HANDLE;
public class JNATest {
private static final int MEM_MAP_SIZE = 5460;
private static final String MEM_MAP_NAME = "MumbleLink";
private final HANDLE sharedFile;
private Pointer sharedMemory;
public JNATest() throws InterruptedException {
int uiVersion = 0;
int uiTick = 0;
float[] fAvatarPosition = new float[0];
float[] fAvatarFront = new float[0];
float[] fAvatarTop = new float[0];
float[] fCameraPosition = new float[0];
float[] fCameraFront = new float[0];
float[] fCameraTop = new float[0];
char[] characterName = new char[0];
char[] gameName = new char[0];
int context_len = 0;
byte[] context = new byte[0];
this.sharedFile = Kernel32.INSTANCE.CreateFileMapping(WinBase.INVALID_HANDLE_VALUE, null, WinNT.PAGE_EXECUTE_READWRITE, 0, MEM_MAP_SIZE, MEM_MAP_NAME);
this.sharedMemory = Kernel32.INSTANCE.MapViewOfFile(this.sharedFile, WinNT.SECTION_MAP_READ, 0, 0, MEM_MAP_SIZE);
while (this.sharedMemory != null) {
uiVersion = this.sharedMemory.getInt(0);
uiTick = this.sharedMemory.getInt(4);
fAvatarPosition = this.sharedMemory.getFloatArray(8, 3);
fAvatarFront = this.sharedMemory.getFloatArray(20, 3);
fAvatarTop = this.sharedMemory.getFloatArray(32, 3);
gameName = this.sharedMemory.getCharArray(44, 256);
fCameraPosition = this.sharedMemory.getFloatArray(556, 3);
fCameraFront = this.sharedMemory.getFloatArray(568, 3);
fCameraTop = this.sharedMemory.getFloatArray(580, 3);
characterName = this.sharedMemory.getCharArray(592, 256);
context_len = this.sharedMemory.getInt(1104);
context = this.sharedMemory.getByteArray(1108, 256);
System.out.println("uiVersion: " + uiVersion);
System.out.println("uiTick: " + uiTick);
System.out.println("fAvatarPosition: " + Arrays.toString(fAvatarPosition));
System.out.println("fAvatarFront: " + Arrays.toString(fAvatarFront));
System.out.println("fAvatarTop: " + Arrays.toString(fAvatarTop));
System.out.println("gameName: " + Arrays.toString(gameName));
System.out.println("fCameraPosition: " + Arrays.toString(fCameraPosition));
System.out.println("fCameraFront: " + Arrays.toString(fCameraFront));
System.out.println("fCameraTop: " + Arrays.toString(fCameraTop));
System.out.println("identity: " + Arrays.toString(characterName));
System.out.println("context_len: " + context_len);
System.out.println("context: " + Arrays.toString(context));
System.out.println("#####################################################");
Thread.sleep(1000);
}
}
public static void main(String[] args) throws InterruptedException {
new JNATest();
}
}
Edit:
It turned out, that if mumble client first creates the mem mapped file and i start my java application after that file is already created, everything works….
Do i need some security settings to get the creation by my java app work?
Edit:
When using PAGE_EXECUTE_READWRITE it works as expected. -> altered code above
(edited by Lulan.8497)
I compared the address and size of the memory mapped file that is created by the mumble client with the one created by my own.
0xFFFFF8A00A581810 vs. 0xFFFFF8A00A581810
They are the same….
I found out, that when there is a Mumble client running an i than start my java application, i’m able to retrieve the data i wish…. Any ideas why?
Edit:
Restartet IDE, Mumble, Eclipse and Java App —> it doesnt work again
(edited by Lulan.8497)
Hello Guys,
since i got no answers here, i investigated the whole problem a bit more by myself.
I used Microsofts Process Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) to check which memory mapped files are opened by which process.
I found out, that my java process has opened “\Sessions\1\BaseNamedObjects\MumbleLink” and the GW2 Process not.
Is that the expected behavior?
I executed my java app with elevated rights an got access to global scope…
that resulted in a ememory mapped file handle \BaseNamedObjects\MumbleLink … well… it didn’t worked out as well..
(edited by Lulan.8497)
Hey,
did anybody figured out how to establish a Mumble Link for position retrieval using JNA (Java Native Access)?
Im stuck… I tried several different setups… Anyway… my current one looks similar to this:
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.WinBase;
import com.sun.jna.platform.win32.WinNT;
import com.sun.jna.platform.win32.WinNT.HANDLE;
HANDLE sharedFile = Kernel32.INSTANCE.CreateFileMapping(WinBase.INVALID_HANDLE_VALUE, null, WinNT.PAGE_EXECUTE_READWRITE, 0, 48, “/MumbleLink”);
Pointer sharedMemory = Kernel32.INSTANCE.MapViewOfFile(this.sharedFile, WinNT.SECTION_QUERY, 0, 0, 48);
final int ret = Kernel32.INSTANCE.WaitForSingleObject(sharedFile, WinBase.INFINITE); System.out.println(Arrays.toString(sharedMemory.getByteArray(0, 48)));
But all i get is a bunch of zeros xD
Here is some small java test class you might start from …
import java.util.Arrays;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.WinBase;
import com.sun.jna.platform.win32.WinNT;
import com.sun.jna.platform.win32.WinNT.HANDLE;
public class JNATest {
private final HANDLE sharedFile;
private final Pointer sharedMemory;
public JNATest() {
// final String name = "MumbleLink." + ManagementFactory.getRuntimeMXBean().getName().split(Pattern.quote("@"))[0];
final String name = "MumbleLink";
System.out.println("filename: " + name);
this.sharedFile = Kernel32.INSTANCE.CreateFileMapping(WinBase.INVALID_HANDLE_VALUE, null, WinNT.PAGE_READWRITE, 0, 48, name);
this.sharedMemory = Kernel32.INSTANCE.MapViewOfFile(this.sharedFile, WinNT.SECTION_MAP_WRITE, 0, 0, 48);
try {
while (true) {
System.out.println(Arrays.toString(this.sharedMemory.getByteArray(0, 48)));
Thread.sleep(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if (!WinBase.INVALID_HANDLE_VALUE.equals(this.sharedFile)) {
Kernel32.INSTANCE.CloseHandle(this.sharedFile);
}
}
}
public static void main(String[] args) throws InterruptedException {
new JNATest();
}
}
(edited by Lulan.8497)
Thank you dr. ishmael, i guess i ran into that…
https://api.guildwars2.com/v1/guild_details.json?guild_id=E4CFA2C4-EBB2-42B9-9534-547A1B5182B9 returns a 500 Error. Am i’m doing something wrong?
I’ll give you some example how my api works:
final IWVWWrapper apiWrapper = YAGW2APICore.getWVWWrapper();
apiWrapper.registerWVWMapListener(new IWVWMapListener() {
@Override
public void notifyAboutObjectiveEndOfBuffEvent(IWVWObjectiveEndOfBuffEvent event) {
// TODO Auto-generated method stub
}
@Override
public void notifyAboutObjectiveCapturedEvent(IWVWObjectiveCaptureEvent event) {
// TODO Auto-generated method stub
}
@Override
public void notifyAboutChangedMapScoreEvent(IWVWMapScoresChangedEvent event) {
// TODO Auto-generated method stub
}
});
apiWrapper.registerWVWMatchListener(new IWVWMatchListener() {
@Override
public void notifyAboutMatchScoreChangedEvent(IWVWMatchScoresChangedEvent event) {
// TODO Auto-generated method stub
}
});
apiWrapper.start();
This is all you got to do do gain information about any wvw change
You can also register for events of only a subset of matches or maps…
And btw. i’d like to have some sourcecode-bbcode for this forum !!!
Hello Guys,
the last few days i wrote a highly sophisticated wvw api wrapper.
To put it in a nutshell, i transform the snapshots provided by arenanets json based api into a well defined object graph and provide an event driven interface. I call this functionality the “core”-module.
Therefore i used
- apache Jersey as the client for the json api
- guice for injections
- guava Framework for utils, caching and eventbus
In addition to this core features i’m actually writing some kind of history tracking and analyzing module using eclipseLink and apache derby database. It connects to the “core”-module and tracks changes, provides statistics etc.
The “core”- and “analyzing”-module will than become used for implementing a sample application.
The whole framework is built using maven.
I’d like to share this whole framework with you guys. But i’d rather share the source than the built artifacts, because i’d like to keep control for future development.
Therefore i need some kind of maven repository.
- Is there anybody out there that already hosts such a repository for gw related artifacts?
- If not, would’t it be nice if arenanet provides those?
Greez