Wowza Community

NetConnection.call parameters not retrievable on server

I’m trying to call a function from an AS3 application with the following signature

public void onPasswordChanged(IClient client, RequestFunction function, AMFDataList params)

But when I call this from the client, it seems the parameters are not retrievable. My AS3 code is as follows

		
		/* JS callback functions */
		public function setPassword(pw:String):void
		{
			trace(printf("setPassword called: %s is new password", pw)); 
			
			this.roomPassword = pw;
			serverCall('onPasswordChanged', this.streamName, this.roomPassword);
		}
		private function serverCall(func:String, ...params):void
		{
			try {
				if ( nc.connected ) {
					nc.call(func, null, params);
				}
			} catch ( e:Error ) {
				trace( "Server Error: "+e.toString() );
			}
		}

On the client, the trace() shows that my params are there. But calling getString(params, PARAM1) on the server returns null, and calling params.getString(PARAM1) results in “19:31:55: ERROR -Category: server -Event: comment -Comment: invoke(onPasswordChanged): java.lang.ClassCastException: com.wowza.wms.amf.AMFDataMixedArray cannot be cast to com.wowza.wms.amf.AMFDataItem: com.wowza.wms.amf.AMFDataList.getString(null:-1)”

What could possibly be wrong here?

Server-side, try:

String param1 = getParamString(params, PARAM1);

If you are returning an AMFDataObj, handle like this client-side:

nc.call("doSomething", new Responder(doSomethingResult), "myData");
function doSomethingResult(obj:Object)
{
for (var prop:String in obj)
{
	trace("\t"+prop+":\t"+obj[prop]);
}
}

Or if returning simple string:

function doSomethingResult(returnStr:String)
{
	trace("doSomething: "+returnStr);
	callResult.text = "doSomething: "+returnStr;
}

Richard

Server-side, try:

String param1 = getParamString(params, PARAM1);

That’s the first thing I tried - it returns null. Using params.getString causes an exception. One thing occurs to me in retrospect however - is it possible that sending the params object passed into my serverCall method is resulting in a single parameter of type AMFDataMixedArray being sent to the server?

(UPDATE: Yes. That’s exactly what it is. I naively assumed that the “params” would be passed unmodified but it appears when it is first passed into an AS3 function it is re-packaged into an array).

If you are returning an AMFDataObj, handle like this client-side:

nc.call("doSomething", new Responder(doSomethingResult), "myData");
function doSomethingResult(obj:Object)
{
for (var prop:String in obj)
{
	trace("\t"+prop+":\t"+obj[prop]);
}
}

Or if returning simple string:

function doSomethingResult(returnStr:String)
{
	trace("doSomething: "+returnStr);
	callResult.text = "doSomething: "+returnStr;
}

Richard

I’m not using responders at this point - this is a blind server call.