Hi,
I’m new to wowza and java.
I am trying to shut down a client from the server, but without a call from flex. I understand that if I have a call from flex, I can do something like:
IClient clientOut=client.getAppInstance().getClientById(client_id);
clientOut.setShutdownClient(true);
But what if I have no call from flex? Then there is no client from which to call the above methods.
Are there static methods that can get a client from its id?
Sorry if this is completely off the mark. I am truly a newbie.
Cam
You can use IApplicationInstance.getClientById(int clientId);
appInstance.getClientById(1234);
Or IVHost.getClient(int clientId, boolean create);
Richard
It depends on the context.
If you have a IClient object you can do this:
import com.wowza.wms.client.*;
public void doSomething(IClient client, RequestFunction function,
AMFDataList params) {
IClient someClient = client.getAppInstance().getClientById(1234);
}
If you have a IMediaStream object you can do this:
import com.wowza.wms.client.*;
public void onStreamCreate(IMediaStream stream) {
IClient someClient = stream.getClient().getAppInstance().getClientById(1234);
}
Richard
Not sure what you are mean. What do you want to do?
The Server-side API is the only language reference. But if you search this forum (using the forum search or google) you can often find more usage info.
Richard
You can do something like this:
public void removeUser(Integer client_id) {
IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
vhost.getClient(client_id, false);
}
But uou will most likely detect that situation in the onConnect handler, where you already have the actual client, so just do it in that handler.
public void onConnect(IClient client, RequestFunction function,
AMFDataList params) {
// find out if client is logged in
client.setShutDownClient(true);
}
Richard
Great! Thanks for the update.
Richard
Hi Richard,
It appears I have a similar problem. How do I instantiate or find an ApplicationInstance from which to call this method?
Thanks for you help.
Cam
Would it be possible to do with a function that has just been passed the client id?
PS. I’ve been looking for descriptions of the java classes but havent been able to find anything except the language reference and the quick start guides. Do you know if there is any more extensive documentation to read?
I’m trying to make a helper function, something like this:
public void removeUser(Integer client_id) {
...
}
For some context, I have a hashmap of AMFDataObj indexed by client ids. The AMFDataObj holds a user id.
What I want to do is disconnect a user when I detect they have logged in twice, on two separate browsers/computers. So the client on their first logged in computer is shutdown automatically when they log in somewhere else.
Hi Richard,
Thanks for the help.
I’ve finally managed to test your suggestions and they seem to work fine.
Thanks!