I'm trying to send message from server to users which has to be originated from the server. I need this because I would like to have some objects in the game that are controlled only by the server. My idea is to use:
public void sendObjectMessage(Room targetRoom,
User sender,
ISFSObject message,
java.util.Collection<User> recipients)
from the server API. However, this function does not accept null as a sender (it hangs). How can I do this in other way? Should I create some user that will represent server? Is it even possible?
This is something you have to write yourself. In your extension, when someone logs into the server, you will want to add them to a list of users, and remove them when they disconnect. Then when you need to send a message to all users, you run through the list and send a message to each one.
I cover creating a World class which holds all users in my dev blog and adding the user when they first connect. You would use this same setup for broadcasting messages to all players.
I don't have problem with recipients. The problem is that I don't have a sender. I want to send message directly from the server. However, for the function which I mentioned I have to specify the sender...
Can you post some code which you exactly use to send such messages from the server to the clients?
Ok, but I would like to send this data from the class (inside the actual extension class) that implements Runnable interface because I have some thread that should send data periodically to the users and I think that this.send will not work.
Hi!
I will give some more details... We want to send message (SFSObject) from SFS2X to all Unity clients. The problem is We would like to do this from class which implements Runnable: