1

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' }) };
    }

}
Emrah Ayanoglu
  • 466
  • 2
  • 6
  • 16

1 Answers1

0

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>
Abe
  • 8,623
  • 10
  • 50
  • 74
  • I am afraid it didn't work.I tried the null delimiter instead of "\0"; however, flash xmlsocket object didn't trigger the message receive event. Also, i tried both null delimiter and "\0" that leads to two messages instead of one message. – Emrah Ayanoglu Jun 08 '12 at 11:04
  • Did you try out the decoder I have linked? You can actually decode and see why exactly the frame is having extra bytes. That may give a clue. – Abe Jun 08 '12 at 12:21