improve - static factory pattern

use static factory pattern for rpc codec