The online racing simulator
InSim + Java -> how to build packages
I'm actually trying to get some InSim to work with Java (I want to keep it portable...). Sending normal UDP Packets already works, but how do I define that ISI struct Scawen mentions in the InSim documentation? I can't really find something how I can get such special packet plugged together...
Can someone give me a kick-off? (or what its called in english...)
A package is just an array of bytes.

So to make the ISI packet you can do something like


byte[] isi = new byte[24];

isi[0] = (byte)'I';
isi[1] = (byte)'S';
isi[2] = (byte)'I';

// .. and so on

Of course there are more efficient ways of doing that, but this should work.
aaah now I undestand what Scawen ment, thanks
I already did some base java classes for insim and a little app for racetracking
in java. I could send it over to u, if u want to have a look on it.
yee that would be great!

-> tanuva AT gmx DOT net
#6 - Stuff
Can I see too how you setup all your classes? I am also in the process of making a Java InSim manager thingy and would like to see what anyone else has created.

In my project, I have setup a class, InSim, and two interfaces. One interface for getting base events (version, messages, state packet, etc) and one for race tracking events. All I need so far. Each packet is a class and the other parts of the program just implement one of the two interfaces to receive InSim events. I also have a JTable setup to show some of the connected player info.

Do you have something similar? Learning by example is one of the better ways imo. Thanks a ton and if you want my code too, trade is OK.
I stopped java development last year. What I did is likly less complete than what u seem to have written.
I did switch from java to c/c++ and using cygwin for crossplattform compiling.
But if u want it ... tell me where to send it.
my code doesn't really work at all up to now, I get LFS to recognize that an ISI packet is arriving, but theres something wrong in my byte order, because, when I add the bytes for flags/adminpw etc to the packet, LFS doesn't seem to recieve it anymore. Maybe I just start off from yankman's code and try to get it to work with mine.
At the end my app wants to become a connection between a LFS server and IRC, so that users can see e.g. race stats. But I've the impression that my coding skill is somewhere about lvl2 and I want to start at lvl20... It will be a lot of work, but maybe I get it to work.

Edit: hmm... a java version of sdether's InSimLib would be the best what could happen to me, but such a holy piece of code doesn't exist, does it? ^^
#9 - abz1
You can have a look at mine aswell if you want, it dosent do anything at the moment... just recevies the packets converts them into something useful but dosent do anything yet, I was about to add a gui interface but stopped. I will most likely continue again in a couple of weeks.
Quote from Tanuva :Edit: hmm... a java version of sdether's InSimLib would be the best what could happen to me, but such a holy piece of code doesn't exist, does it? ^^

Not wanting to start a language preference war, but any reason you can't do it in .NET or mono? If you know java, C# isn't much of a stretch. As for porting my lib to java, a lot of things would probably port over fairly simply, but i do use properties, events/delegates and structs a lot, which are fairly .NET specific in syntax.
A lib with all the usefull functions is fine, but I have different things in mind.
My goal is to implement a Socket-Server that does all things belonging to InSim and specially to dedicated lfs hosts. (Just like jogdive did)
It should be used freely by any clients via an open protocol (still to define) and have the ability to handle plugins via some kind of small api.
At least it should be cross plattform (i try to do it posix compatible) and have no gui ( the big difference to jogdives approach ).
Quote from sdether :Not wanting to start a language preference war, but any reason you can't do it in .NET or mono? If you know java, C# isn't much of a stretch. As for porting my lib to java, a lot of things would probably port over fairly simply, but i do use properties, events/delegates and structs a lot, which are fairly .NET specific in syntax.

My "problem" is, that I want to get more familiar with Java to get computer science in grade 11 easier where we are going to use Java. Another point is, that I want to keep my code cross-platform and the easiest solution für that is Java, because I don't have to use 100 millions of librarys to get the posix-compatible code to do what I want it to.
(in addition, C# is microsoft-made, which makes it a don't-touch for me...)
Quote from Tanuva :Another point is, that I want to keep my code cross-platform and the easiest solution für that is Java, because I don't have to use 100 millions of librarys to get the posix-compatible code to do what I want it to.
(in addition, C# is microsoft-made, which makes it a don't-touch for me...)

I suggest you take a look at www.mono-project.com before you reject C# for non-portable and MS evilness. My lib runs great under RedHat and Mac OS X using mono.

Of course your first reason is perfectly valid, so good luck with java. Building a lib for insim in java would be something useful to the community, since there are plenty of people using it. And surely there'd be more if someone went through the exercise of wrapping insim with a lib for java.
Hmm... Idea:
Maybe I could just try to start off from Yankman's code, that would shorten and simplify work massively... Would you allow that, Yankman? ^^
[there won't come out much the next days, first I gotta familiarise myself with it]
Sure u can use it. There is no copyright are anything in this direction.
If there are questions feel free to ask.

PS: But don't tell this ur teacher.
Quote from yankman :PS: But don't tell this ur teacher.

I think he won't be interested in a prog I'm writing for communicating with a racing simulator... He's a geek, sure, but he doesn't play computer games iirc
I can post what I have maybe tonight or tomorrow. We (RiCiN and I) still have to package it, create a few more classes, tweak it and a few more javadocs/comments.

A plugin system I could see because only thing a program has to do is use the main InSim class and setup a listener, just like ActionListeners for buttons or whatnot. The InSim class handles the connection, keep alive, verification ACKs, and raises events then passes the packet/class to each of its listeners. Simple right?

And speaking of school projects, I too am using this for my Java class.
school projects... Mine is not a school project, I'm doing this just for fun. I only want to get familiar with the Java language to make school easier ;D

@Stuff: I'm anxious to see what you done ...

FGED GREDG RDFGDR GSFDG