collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: AOChat Lib for Java  (Read 10412 times)

0 Members and 1 Guest are viewing this topic.

Offline Astaso

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
AOChat Lib for Java
« on: February 09, 2010, 10:20:00 pm »
Hello everybody,
i did a research in the internet and tried to find a Java library for AoC.
I found a lib coded by quaseem, which looks really interesting.

So i am a java developer by myself and wanted to rewrite the ao lib for aoc.

I look into the bebot code to understand what exactly has to be changed to get the ao lib working,
i dont wanna do all that from scratch.
But i am not very good in php, i know that java and php have a great deal in common,
but at the hard points there is a single mistake a heavy time lose.
I hope you understand what i mean.

So my question at this point is:
can somebody give me an example of what actually needs to be done to get connected to the chat servers?

I mean an example like:

1. send login cookie to the server  ( byte[Int,String,xxx] )
2. receive answer package ( byte[xxwhatever comesxx] )
3...
x. connected and bot logged in fully authenticated

Thanks for your patience, i hope someone is willing to help me a lil bit.
I just need the AoC Protocol definition, to know what i have to sent to get connected.

Offline Astaso

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #1 on: February 13, 2010, 03:59:45 pm »
nobody willing or able to give me some informations?
Ok lets do it step by step..:

After sniffing all the packets with wireshark, i found out, that the login process works like ths:

First connecting to the first server at (EU) port 7000
i think this is necessary to get the available chars from the account name.

Second Server is port 7011, this port was given by the first server and i think
there you can select the char to get the char id.

And finally you come to the chat server which is port 7002 where you can login with the char id.

My question here is:
if u know the char id, is it necessary to connect to the 2 other servers to login?
Is there a key in the server seed to connect to the third server, which i must get from the second?

I tried to connect to the first, but i didnt managed to repack the first packet i think.

its this part:

Code: [Select]
// Create the RPC header
$header1 = pack("n", strlen($callername)) . $callername . pack("N2", $instance, 0);
$header2 = pack("n", strlen($endpointname)) . $endpointname . pack("N2", 0, 0);
$header = $header1 . $header2 . pack("N", $packet->type);

// Create the datablock (header+data)
$data = $header . $packet->data;

// Create the checksum for the packet
$packet->crc = crc32($data);
$data = pack("N", $packet->crc) . $data;

// Add the packetsize in the header
$data = pack("N", strlen($data) ) . $data;

if(is_resource($this->debug))
{
fwrite($this->debug, ">>>>>\n");
fwrite($this->debug, $data);
fwrite($this->debug, "\n=====\n");
}

socket_write($this->socket, $data, strlen($data));
as far as i understood the packet structure is: SSI
So i have a problem with the first String, where you put the $header

I had a look at the pack function, but i didnt find the "N2" parameter definition.

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: AOChat Lib for Java
« Reply #2 on: February 13, 2010, 05:33:42 pm »
I do not know the AoC protocol well myself unfortunately, and the code we use for BeBot was not created by us as it stands.

What you have is pretty much correct afaik.

You cannot bypass the Universe server or the territory server and go directly to the chat server unfortunately.

The seed I'm not sure about offhand, again since I'm more familiar with AO and not AoC where we still log directly into the chatserver as we originally did with AoC as well. But we store the server seed in $this->serverseed and it is used in connecting to all 3 servers.

Regarding pack() the documentation is located at http://no2.php.net/pack
Where you can find that
Quote
string pack  ( string $format  [, mixed $args  [, mixed $...  ]] )

Regarding format
Quote
The format  string consists of format codes followed by an optional repeater argument. The repeater argument can be either an integer value or * for repeating to the end of the input data. For a, A, h, H the repeat count specifies how many characters of one data argument are taken, for @ it is the absolute position where to put the next data, for everything else the repeat count specifies how many data arguments are consumed and packed into the resulting binary string.

And
Quote
H =     Hex string, high nibble first

Thus H2 becomes Hex string, high nibble first, where 2 characters of one data argument is taken.

You might also be interested in looking at ConanChat which is written in C++ iirc and the code could be easier to follow.
http://www.conanchat.com/

Hope this helps a little.
BeBot Founder and Fixer Kingpin

Offline Astaso

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #3 on: February 13, 2010, 06:12:24 pm »
That helped a little bit yes, now i really think if i am able to do that all from scratch up.. :/

"Thus H2 becomes Hex string, high nibble first, where 2 characters of one data argument is taken."

meens:
this: pack("N2", 0, 0);
becomes a long which is converted into a String = "0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000" (32 bit (N2 = long(0) + long(0) ) )

and this:
pack("n", strlen("AB")
would be: 
a short = "0000 0000 0000 0100" (16 bit (n = short(2) ) )

am i right with this guess?
If u answer me this, i think im able to do the rest on my own..
really much thx for the infos u gave me already.

Offline Astaso

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #4 on: February 14, 2010, 11:09:54 pm »
Ok i sent the first successful login package to the server and got a response.
Thx for the infos which leaded my way to this success. :)
i will elt u know when i am done with the lib. bye then. :)

Offline Chaoz

  • BeBot User
  • **
  • Posts: 50
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #5 on: February 15, 2010, 07:54:37 am »
Heya :)

If you have any problems with the java implementation just send me a poke.

I am currently porting my Conan Chat client from c++ to java/android.

Btw did you know that the reason AO/AoC has bots in the first place is that FC made a java client that someone reverse engineered :)

Chaoz
AoC Junkie.
Check out conanchat http://www.conanchat.com/index.php?id=3 a windows chat client for Age Of Conan

Offline Astaso

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #6 on: February 17, 2010, 05:55:09 pm »
fine, i wouldnt say no for a helpin hand.
just write me an email if u really wanna help:
info(at)pirates-of-main.de

Offline Astaso

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #7 on: March 10, 2010, 05:23:50 pm »
Ok, i finally got it..
i succesfully connected to the chat servers with my Java AOChat lib.

Thx for the startadvices to understand the php code. :)

i will offer my code after i cleaned it up as well.

Offline TBK

  • BeBot User
  • **
  • Posts: 26
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #8 on: March 11, 2010, 06:27:40 pm »
Should should upload it to aoc.curse.com, since it is the main spots for AoC stuff :)

Offline Astaso

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #9 on: April 25, 2010, 03:54:46 pm »
so first version is done:
http://code.google.com/p/jaocbot/

Offline Heinz64

  • BeBot Rookie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #10 on: April 29, 2010, 02:19:07 am »
hi

this may be a bit OT, but only a bit ;)    otherwise delete this



I'm searching an up to date msg-parser or whole chat lib for AO in java or c/c++.
with the lib i used so far i can login to the server and get some input, but the parser isnt realy useful and the modul terminates because of io exceptions..

and because this thread is titled "AOChat Lib for Java" i wonder, if this lib is also useable for AO too

if not, can someone post a link or something else where i can find something like this ?
« Last Edit: April 29, 2010, 02:44:35 am by Heinz64 »

Offline Astaso

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #11 on: April 30, 2010, 08:02:55 am »
It think it shouldnt be a problem to rewrite this lib to work with AO aswell.
I developed the lib to be dynamic, you simply have to rewrite a ServerCommunicator in my lib and add the AO specific Msges to the EMessageDef Enum. Then add the communicator to the comm list and remove the aoc communicators.

But right now it wont work with AO, cause its written for AOC.
I Cant do it, i dont have an AO account, so i cannot test.

Offline Tyrence

  • BeBot User
  • **
  • Posts: 41
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #12 on: April 30, 2010, 12:10:28 pm »
@Heinz64 I have a bot framework I've written in java that I might work for you.  can you explain a little more what you are trying to do?

Offline Heinz64

  • BeBot Rookie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: AOChat Lib for Java
« Reply #13 on: April 30, 2010, 03:51:45 pm »
i try to write a framework in java with botmanager, separation of chat modules (like ao, aoc, irc, any other chat protocol you write a module for), bot modules ( the active part in the framework) and function modules ( providing services for the bots) and the possibility to (un-)load them without restarting the framework or even a single bot. with using multithreading this should be nearly endless scaleable .. your computer or may be the central dispatcher should be the only limitation.

in this way, a single bot can have multiples chat modules, e.g. for better spamming announces, relay between orgs, servers, games, chat protocols, what ever you want ..

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 470
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal