question: public void doEncodeSharedObject ( ISharedObjectMessage so , RTMP rtmp , IoBuffer out ) { final Output output = new org . red5 . io . amf . Output ( out ) ; output . putString ( so . getName ( ) ) ; out . putInt ( so . getVersion ( ) ) ; out . putInt ( so . isPersistent ( ) ? 2 : 0 ) ; out . putInt ( 0 ) ; int mark , len ; for ( ISharedObjectEvent event : so . getEvents ( ) ) { byte type = SharedObjectTypeMapping . toByte ( event . getType ( ) ) ; switch ( event . getType ( ) ) { case SERVER_CONNECT : case CLIENT_INITIAL_DATA : case CLIENT_CLEAR_DATA : out . put ( type ) ; out . putInt ( 0 ) ; break ; case SERVER_DELETE_ATTRIBUTE : case CLIENT_DELETE_DATA : case CLIENT_UPDATE_ATTRIBUTE : out . put ( type ) ; mark = out . position ( ) ; out . skip ( 4 ) ; output . putString ( event . getKey ( ) ) ; len = out . position ( ) - mark - 4 ; out . putInt ( mark , len ) ; break ; case SERVER_SET_ATTRIBUTE : case CLIENT_UPDATE_DATA : if ( event . getKey ( ) == null ) { Map < ? , ? > initialData = ( Map < ? , ? > ) event . getValue ( ) ; for ( Object o : initialData . keySet ( ) ) { out . put ( type ) ; mark = out . position ( ) ; out . skip ( 4 ) ; String key = ( String ) o ; output . putString ( key ) ; serializer . serialize ( output , initialData . get ( key ) ) ; len = out . position ( ) - mark - 4 ; out . putInt ( mark , len ) ; } } else { out . put ( type ) ; mark = out . position ( ) ; out . skip ( 4 ) ; output . putString ( event . getKey ( ) ) ; serializer . serialize ( output , event . getValue ( ) ) ; len = out . position ( ) - mark - 4 ; out . putInt ( mark , len ) ; } break ; case CLIENT_SEND_MESSAGE : case SERVER_SEND_MESSAGE : out . put ( type ) ; mark = out . position ( ) ; out . skip ( 4 ) ; serializer . serialize ( output , event . getKey ( ) ) ; for ( Object arg : ( List < ? > ) event . getValue ( ) ) { serializer . serialize ( output , arg ) ; } len = out . position ( ) - mark - 4 ; out . putInt ( mark , len ) ; break ; case CLIENT_STATUS : out . put ( type ) ; final String status = event . getKey ( ) ; final String message = ( String ) event . getValue ( ) ; out . putInt ( message . length ( ) + status . length ( ) + 4 ) ; output . putString ( message ) ; output . putString ( status ) ; break ; default : out . put ( type ) ; mark = out . position ( ) ; out . skip ( 4 ) ; output . putString ( event . getKey ( ) ) ; serializer . serialize ( output , event . getValue ( ) ) ; len = out . position ( ) - mark - 4 ; out . putInt ( mark , len ) ; break ; } } }
target:  Perform the actual encoding of the shared object contents.