Jump to content
  • 0
MaxiPad

Error when sending String

Question

Hey all, i've just tried to add a new clan chat system with ranks, but for some reason when i leave the clan i get this error:
[code][8/07/14 19:45]: java.lang.ArrayIndexOutOfBoundsException: 0
[8/07/14 19:45]: at com.divine.security.Stream.readString(Stream.java:283
)
[8/07/14 19:45]: at com.divine.game.mobile.player.action.ReceiveString.pr
ocessPacket(ReceiveString.java:14)
[8/07/14 19:45]: at com.divine.game.mobile.player.PacketHandler.processPa
cket(PacketHandler.java:151)
[8/07/14 19:45]: at com.divine.game.mobile.player.Client.processQueuedPac
kets(Client.java:1025)
[8/07/14 19:45]: at com.divine.game.mobile.player.PlayerHandler.process(P
layerHandler.java:212)
[8/07/14 19:45]: at server.Server$1.execute(Server.java:196)
[8/07/14 19:45]: at com.divine.server.task.Task2.tick(Task2.java:117)
[8/07/14 19:45]: at com.divine.server.task.TaskScheduler.run(TaskSchedule
r.java:104)
[8/07/14 19:45]: at java.util.concurrent.Executors$RunnableAdapter.call(E
xecutors.java:471)
[8/07/14 19:45]: at java.util.concurrent.FutureTask.runAndReset(FutureTas
k.java:304)
[8/07/14 19:45]: at java.util.concurrent.ScheduledThreadPoolExecutor$Sche
duledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
[8/07/14 19:45]: at java.util.concurrent.ScheduledThreadPoolExecutor$Sche
duledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[8/07/14 19:45]: at java.util.concurrent.ThreadPoolExecutor.runWorker(Thr
eadPoolExecutor.java:1145)
[8/07/14 19:45]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(Th
readPoolExecutor.java:615)
[8/07/14 19:45]: at java.lang.Thread.run(Thread.java:744)
[8/07/14 19:45]: Legit Yonas is sending invalid PacketType: 153. PacketSize: 2
[8/07/14 19:45]: Game saved for player Legit Yonas
[8/07/14 19:45]: LOGGED OUT: Legit Yonas[/code]
and as you can see it loggs off the character.
the removing from clan is done client sided through this:
[code]case 18129:
if (R_3.interfaceCache[18135].message.toLowerCase()
.contains("join")) {
inputTaken = true;
inputDialogState = 0;
messagePromptRaised = true;
promptInput = "";
friendsListAction = 6;
aString1121 = "Enter the name of the chat you wish to join";
} else {
sendString(0, "");
}
break;[/code]
[code]public void sendString(int identifier, String text) {
text = identifier + "," + text;
stream.createFrame(127);
stream.writeWordBigEndian(text.length() + 1);
stream.writeString(text);
}[/code]
the joining works fine, but the leaving doesnt

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0
[quote name='MaxiPad']Hey all, i've just tried to add a new clan chat system with ranks, but for some reason when i leave the clan i get this error:
[code][8/07/14 19:45]: java.lang.ArrayIndexOutOfBoundsException: 0
[8/07/14 19:45]: at com.divine.security.Stream.readString(Stream.java:283
)
[8/07/14 19:45]: at com.divine.game.mobile.player.action.ReceiveString.pr
ocessPacket(ReceiveString.java:14)
[8/07/14 19:45]: at com.divine.game.mobile.player.PacketHandler.processPa
cket(PacketHandler.java:151)
[8/07/14 19:45]: at com.divine.game.mobile.player.Client.processQueuedPac
kets(Client.java:1025)
[8/07/14 19:45]: at com.divine.game.mobile.player.PlayerHandler.process(P
layerHandler.java:212)
[8/07/14 19:45]: at server.Server$1.execute(Server.java:196)
[8/07/14 19:45]: at com.divine.server.task.Task2.tick(Task2.java:117)
[8/07/14 19:45]: at com.divine.server.task.TaskScheduler.run(TaskSchedule
r.java:104)
[8/07/14 19:45]: at java.util.concurrent.Executors$RunnableAdapter.call(E
xecutors.java:471)
[8/07/14 19:45]: at java.util.concurrent.FutureTask.runAndReset(FutureTas
k.java:304)
[8/07/14 19:45]: at java.util.concurrent.ScheduledThreadPoolExecutor$Sche
duledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
[8/07/14 19:45]: at java.util.concurrent.ScheduledThreadPoolExecutor$Sche
duledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[8/07/14 19:45]: at java.util.concurrent.ThreadPoolExecutor.runWorker(Thr
eadPoolExecutor.java:1145)
[8/07/14 19:45]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(Th
readPoolExecutor.java:615)
[8/07/14 19:45]: at java.lang.Thread.run(Thread.java:744)
[8/07/14 19:45]: Legit Yonas is sending invalid PacketType: 153. PacketSize: 2
[8/07/14 19:45]: Game saved for player Legit Yonas
[8/07/14 19:45]: LOGGED OUT: Legit Yonas[/code]
and as you can see it loggs off the character.
the removing from clan is done client sided through this:
[code]case 18129:
if (R_3.interfaceCache[18135].message.toLowerCase()
.contains("join")) {
inputTaken = true;
inputDialogState = 0;
messagePromptRaised = true;
promptInput = "";
friendsListAction = 6;
aString1121 = "Enter the name of the chat you wish to join";
} else {
sendString(0, "");
}
break;[/code]
[code]public void sendString(int identifier, String text) {
text = identifier + "," + text;
stream.createFrame(127);
stream.writeWordBigEndian(text.length() + 1);
stream.writeString(text);
}[/code]
the joining works fine, but the leaving doesnt[/QUOTE]

its an outofboundsexception

java docs are your best solution when it comes to things like this

[url]http://docs.oracle.com/javase/6/docs/api/java/lang/ArrayIndexOutOfBoundsException.html[/url]

Share this post


Link to post
Share on other sites
  • 0
Sending an empty string means the Stream is adding nothing to its buffer. However your length says otherwise. Reading this would result in an error because the length says "i got data" and the buffer says "i got nothing".

That's my guess at first glance.

[B]EDIT:[/B]
Code in question:
[code]
stream.writeWordBigEndian(text.length() + 1);
stream.writeString(text);
[/code]

And since the error occurs on server side it means that the transfer of the empty buffer did not go well, maybe there is some piece of code in your streams that prevent empty stuff so the buffer is null or something. Did you try sending something not empty instead?

Note: It is just a guess, I don't know how 317 works and the guess came out of some logical thinking. Could be entirely wrong. Could be right. Edited by Arix

Share this post


Link to post
Share on other sites

×