jeff, i added a few println before the simtask operations. it seems that the outbuff is null/empty. i’m puzzled. how comes it doesnt works here as the coding is exactly the same as earlier working version. ???
code provided in the swordworld:
GLOReference myRef = simTask.lookupReferenceFor(this);
String out = roomGLO.getDescription(myRef);
ByteBuffer outbuff = ByteBuffer.allocate(out.length());
outbuff.put(out.getBytes());
simTask.sendData(appChannel,from,outbuff,true);
my code:
GLOReference myRef = simTask.lookupReferenceFor(this);
String out = roomGLO.getDescription(myRef);
byte[] dest = new byte[out.length()];
System.out.println("in player: roomGLO description = " + out);
System.out.println("in player: description length = " + out.length());
System.out.println("in player: data.getBytes = " + out.getBytes());
ByteBuffer outbuff = ByteBuffer.allocate(out.length());
outbuff.put(out.getBytes());
System.out.println("appChannel: " + appChannel);
System.out.println("send to userID: " + from);
System.out.println("send to outbuff: " + outbuff.get(dest));
simTask.sendData(appChannel,from,outbuff,true);
output:
User ID =UUID(1150464745429:-6021726462601109706)dataReceived =lookfrom
User ID =UUID(1150464745429:-6021726462601109706)in player: roomGLO description = You are in A big brightly lit room. containing:
A shiney new sword
With you in the room are:
in player: description length = 93
in player: data.getBytes = [B@2344b18f
appChannel: UUID(1150429122430:4214629083300757772)
send to userID: UUID(1150464745429:-6021726462601109706)
Failed to create this-reference
java.nio.BufferUnderflowException
at java.nio.HeapByteBuffer.get(HeapByteBuffer.java:127)
at java.nio.ByteBuffer.get(ByteBuffer.java:674)
at com.sun.gi.apps.swordworld.Player.userDataReceived(Player.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.gi.logic.impl.SimTaskImpl.execute(SimTaskImpl.java:186)
at com.sun.gi.logic.impl.SimThreadImpl.run(SimThreadImpl.java:105)