public void masquerade ( ChannelProxy cloneProxy ) throws InvalidChannelName { ChannelImpl originalChannel = this . _channel ; ChannelImpl cloneChannel = cloneProxy . _channel ; cloneChannel . masquerade ( this . _channel ) ; // detach the hangup listeners originalChannel . removeListener ( this ) ; cloneChannel . removeListener ( cloneProxy ) ; // Now we swap the channels. this . _channel = cloneChannel ; cloneProxy . _channel = originalChannel ; // Now re-attach the hangup listeners this . _channel . addHangupListener ( this ) ; cloneProxy . _channel . addHangupListener ( cloneProxy ) ; logger . debug ( originalChannel + " Channel proxy now points to " + this . _channel ) ; }
Used to handle a MasqueradeEvent . We essentially swap the two underlying channels between the two proxies .