Skip to main content

programming questions: hide user, get distance to cell, get user-name, DB

8 replies [Last post]
hermetic_cab
Offline
Joined: 2008-06-22
Points: 0

Hi,
I have some programming questions, maybe someone can point me to tutorials, infos how to archive those (I have read the four tutorials, but those dont cover that).

1.) I wonder if its possible to hide a user from other (for example make 'admin' invisible), how would that been done?

2.) I would get the distance a user has to a cell (for example to start an animation when one is near), how do I get this info?

3.) Is there a way to get the client name, (who clicks on a cell for example)?

4.) How do I get access/fields of the built-in DB, what do I need for such?

thanks in advance!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jagwire
Offline
Joined: 2008-06-21
Points: 0

hermetic_cab,

1) Hmm...good question. An "ignore" button could be kinda cool I think, this will take some looking into.

2) Right now, you can get the current position of the avatar, but figuring out the distance between your avatar and an arbitrary point in space is a bit trickier. Currently though, there is a proximity component that can be added to a cell to signal when an avatar is a certain distance from that cell. I've only ever found programmatic uses for it though. I've never been able to use it from the object editor. Is there a particular behavior you're looking for?

3) Certainly, although I only know how to do it server side when a message is sent to the server. Maybe a solution could be when a cell is clicked on, the client sends a message to the cellMO and the cellMO sends a message back with the client info? Is there a particular use case you are thinking of?

4) No idea, someone else will need to comment.

Sorry I can't be of more help,
jW

hermetic_cab
Offline
Joined: 2008-06-22
Points: 0

> 1) Hmm...good question. An "ignore" button could be kinda cool I think, this will take some looking into.

thank you!

> 2) I've only ever found programmatic uses for it though. I've never been able to use it from the object editor. Is there a particular behavior you're looking for?

Sure for example look at 'the snowman game' on darkstar, where you can 'pick' the flag. ;)

> 3) Certainly, although I only know how to do it server side when a message is sent to the server.

This is the way I thought of, I only need an idea how I can get the username of an client-id.

> Sorry I can't be of more help.

No, this helped me a lot, I think I will look on 2.) on portal-code, guess such proximility is used there?
Hope someone can help with 4.) too.
Thank you very much!

jagwire
Offline
Joined: 2008-06-21
Points: 0

hermetic_cab,

RE: 3)

Given you already have a WonderlandClientID,
[code]

UserMO user;
try {
user = UserManager.getUserManager().getUser(clientID);
userDisplayname = user.getUsername();
} catch(Exception e) {
//error handling here
}

[/code]

The above code is a common pattern we use in MessageReceiver's in CellMO objects. Let me know if you'd like a complete example. Inside userDisplayname will be your name.

RE: RE: 2) I recommend looking in the portal component more so than the portal cell. The portal cell is actually an extremely clever cell factory which makes use of a ModelCellServerState and a portal component attached.

Best Regards,
jW

hermetic_cab
Offline
Joined: 2008-06-22
Points: 0

2.)Successfully added a proximility sensor to the CellShape example, yupee.
Thank you for the help jW! ;)

Sadly guess I may have missed something to add from portal-example: When I delete the CellShape now totally from world I get this error:
17.02.2010 16:59:34 com.sun.sgs.client.simple.SimpleClient$SimpleClientConnectionListener handleSessionMessage
WARNUNG: SimpleClientListener.receivedMessage callback throws
java.lang.NullPointerException
at org.jdesktop.wonderland.modules.shape.client.ShapeCell.setStatus(ShapeCell.java:107)
at org.jdesktop.wonderland.client.cell.CellCacheBasicImpl.setCellStatus(CellCacheBasicImpl.java:351)
at org.jdesktop.wonderland.client.cell.CellCacheBasicImpl.unloadCell(CellCacheBasicImpl.java:250)
at org.jdesktop.wonderland.client.cell.CellCacheConnection.handleMessage(CellCacheConnection.java:134)
at org.jdesktop.wonderland.client.cell.CellCacheConnection.handleMessage(CellCacheConnection.java:96)
at org.jdesktop.wonderland.client.comms.BaseConnection.messageReceived(BaseConnection.java:125)
at org.jdesktop.wonderland.client.comms.WonderlandSessionImpl$ClientRecord.handleMessage(WonderlandSessionImpl.java:1033)
at org.jdesktop.wonderland.client.comms.WonderlandSessionImpl.fireSessionMessageReceived(WonderlandSessionImpl.java:499)
at org.jdesktop.wonderland.client.comms.WonderlandSessionImpl$WonderlandClientListener.receivedMessage(WonderlandSessionImpl.java:795)
at com.sun.sgs.client.simple.SimpleClient$SimpleClientConnectionListener.handleSessionMessage(SimpleClient.java:601)
at com.sun.sgs.client.simple.SimpleClient$SimpleClientConnectionListener.handleApplicationMessage(SimpleClient.java:482)
at com.sun.sgs.client.simple.SimpleClient$SimpleClientConnectionListener.receivedMessage(SimpleClient.java:442)
at com.sun.sgs.impl.client.simple.SimpleClientConnection.bytesReceived(SimpleClientConnection.java:170)
at com.sun.sgs.impl.io.SocketConnection.filteredMessageReceived(SocketConnection.java:144)
at com.sun.sgs.impl.io.CompleteMessageFilter.processReceiveBuffer(CompleteMessageFilter.java:138)
at com.sun.sgs.impl.io.CompleteMessageFilter.filterReceive(CompleteMessageFilter.java:103)
at com.sun.sgs.impl.io.SocketConnectionListener.messageReceived(SocketConnectionListener.java:128)
at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived(AbstractIoFilterChain.java:703)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:362)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:54)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:800)
at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:247)
at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:307)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)

Any tip what I forgotten to add to prevent this error would be nice.

5.) A new question, I saw every user can remove the collision test of objects via menu.
I think its hard to write game-like behavior, if people can easily escape 'throu walls'.
Should'nt such a possibility be inside a container-node, so an admins can prevent users to switch the avatar-collision off on parts of a world?

How can I disable that possibility for (a) user(s) on server generally (as a fast fix)?

jagwire
Offline
Joined: 2008-06-21
Points: 0

hermetic_cab,

Would it be possible to post the contents of your ShapeCell's setStatus method so we can see exactly what might be throwing the NPE?

RE: 5), I'm looking into this at the moment, but it doesn't look like there's a solid way to do this without altering core code. The next place to look would be the avatar code, I'll let you know what I find.

Best Regards,
jW

jagwire
Offline
Joined: 2008-06-21
Points: 0

hermetic_cab,

Here's a short term solution until security can integrated into the avatar system:
[code]

CollisionChangeRequestListener collisionChangeRequestListener = new CollisionChangeRequestListener();
ClientContextJME.getInputManager().addGlobalEventListener(collisionChangeRequestListener);

// ripped from AvatarImiJME.java
public class CollisionChangeRequestListener extends EventClassListener {

private AvatarCollisionChangeRequestEvent evt=null;

private Class[] consumeClasses = new Class[]{
AvatarCollisionChangeRequestEvent.class,
};

@Override
public Class[] eventClassesToConsume() {
return consumeClasses;
}

@Override
public void commitEvent(Event event) {
}

@Override
public void computeEvent(Event evtIn) {
synchronized(this) {
evt = (AvatarCollisionChangeRequestEvent) evtIn;
if (!evt.isCollisionResponseEnabled()) {
ClientContextJME.getInputManager().postEvent(new AvatarCollisionChangeRequestEvent(!evt.isCollisionResponseEnabled(), evt.isGravityEnabled()));
}
}
}
}
[/code]

The gist of it is that whenever a message is posted to enable/disable collision the above listener will see it and if it's turning collision off, the listener turns it back on. You could add logic to the code such that it turns the listener on and off when needed so it's a bit more scalable.

Hope this helps,
jW

hermetic_cab
Offline
Joined: 2008-06-22
Points: 0

> jagwire: Would it be possible to post the contents of your ShapeCell's setStatus method so we can see exactly what might be throwing the NPE?

Sure, but checked it again: Looks like the plain "shape" module '.tar.gz (Linux/UNIX/Mac OSX)' here:
http://wiki.java.net/bin/view/Javadesktop/ProjectWonderlandWorkingWithMo...
( http://wonderland.dev.java.net/wiki/modules/shape-tutorial-module.tar.gz )
produces that same error on cell delete too?
Could it be that its outdated? (Im using 'Version: 0.5-dev (rev. 4274)' from source )

5.)
>// ripped from AvatarImiJME.java

hum, never been in that deep places before ;)
Hope it goes not too much over my head...
The importent code part is this, right?:
ClientContextJME.getInputManager().postEvent(new AvatarCollisionChangeRequestEvent([b]!evt.isCollisionResponseEnabled()[/b], evt.isGravityEnabled()));

thanks JW!

jagwire
Offline
Joined: 2008-06-21
Points: 0

hermetic_cab,

RE: 5) Basically it creates a class that always turns collision on. While the highlighted method is important, the whole of the parts is most important, no one part is more important than another. That particular line just posts a new event saying to turn collision on..

Still looking into the shape cell...

Best Wishes,
jW