Development > Coding and development discussion

AOChat Lib for Java

(1/3) > >>

Astaso:
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.

Astaso:
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: ---// 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));

--- End code ---
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.

Khalem:
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 $...  ]] )

--- End quote ---

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.

--- End quote ---

And

--- Quote ---H =     Hex string, high nibble first

--- End quote ---

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.

Astaso:
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.

Astaso:
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. :)

Navigation

[0] Message Index

[#] Next page

Go to full version