简体   繁体   中英

Netty Flash XmlSocket Message Receiving Error

I am creating my own flash game server in netty. I'm using flash policy server in the port 843 and game server port in the 8080... Also, I'm using zerodelimeter for framer; however, when i receiving messages on the flash client, i got two messages instead of one message. First message is the real message that i should get; however, the second one is the empty message. How can i avoid the second message receiving in the netty side?

Thanks,

In the below, you can look at the my ChannelPipelineFactory...

    public class SocketServerPipelineFactory implements ChannelPipelineFactory {

    public ChannelPipeline getPipeline() throws Exception {
        PlayerController controller = PlayerController.createPlayerController();

        ChannelPipeline pipeline = Channels.pipeline();

        pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192,
                zeroDelimiter()));
        pipeline.addLast("decoder", new StringDecoder(CharsetUtil.UTF_8));
        pipeline.addLast("encoder", new StringEncoder(CharsetUtil.UTF_8));

        pipeline.addLast("handler", new SocketServerHandler(controller));

        return pipeline;
    }

    public static ChannelBuffer[] zeroDelimiter() {
        return new ChannelBuffer[] { ChannelBuffers.wrappedBuffer(new byte[] { '\0' }),
                ChannelBuffers.wrappedBuffer(new byte[] { '\r', '\n' }) };
    }

}

I think you should be using nul delimiter instead of 0. Here is a netty game server which serves flash policy file. The policy server is running at 843. Pasted below is the relevant spring configuration and here is the policy file decoder for reference.

<!-- Configure the Flash policy server. By default it runs at 843 -->
<bean id="flashPolicyServer" class="org.menacheri.jetserver.server.netty.FlashPolicyServer"
    init-method="createServerBootstrap" destroy-method="stopServer">
    <property name="pipelineFactory" ref="flashPolicyServerPipelineFactory"></property>
    <property name="gameAdminService" ref="gameAdminService"></property>
    <property name="portNumber" value="${flash.policy.port}"></property>
</bean>

<!-- All the pipeline factory beans are now defined -->
<bean id="flashPolicyServerPipelineFactory" class="org.menacheri.jetserver.server.netty.FlashPolicyServerPipelineFactory">
    <lookup-method name="getFlashPolicyServerHandler" bean="flashPolicyServerHandler"/>
    <property name="timer" ref="hashedWheelTimer"></property>
</bean>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM