Results 1 to 2 of 2

Thread: How does one utilise the onConnect(Accept|Reject)? methods properly?

Hybrid View

  1. #1

    Default How does one utilise the onConnect(Accept|Reject)? methods properly?

    I would like to add the user's Id say to a HashMap filled with those users that are connected.

    So in flex I'd like to call:

    Code:
    conn.connect("rtmp://" + SERVER + "/app_1/" + instanceName, userId);
    I'm not sure what to do next. I assume the userId should not be added in onConnect(), in case the connection fails. If so, how would I add it in onConnectAccept(), which only takes the IClient as a parameter?

  2. #2
    Join Date
    Dec 2007
    Posts
    25,630

    Default

    Take a look at this example:

    http://www.wowzamedia.com/forums/sho...Authentication

    You can add user to a hashmap. You can also add info the IClient Properties container.

    Code:
    public void onConnect(IClient client, RequestFunction function,
    			AMFDataList params) {
    		getLogger().info("onConnect: " + client.getClientId());
    		String userName = getParamString(params, PARAM1);
    		client.getProperties().setProperty("userName", userName);
    	}
    Then you can retrieve in any function with IClient argument:

    Code:
    public void onConnectAccept(IClient client) {
    		getLogger().info("onConnectAccept: " + client.getClientId());
    		String userName = client.getProperties().getPropertyStr("userName");
    	}
    Richard

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •