Failed to build a middleman to pass connection between a server and a client

egg86 egg86_tam at yahoo.com
Mon Jan 17 02:33:23 EST 2011


Hi Norman,

I have Server and serverInterface bind together, and Client and
clientInterface bind together. When Client send a string to clientInterface,
clientInterface will call a public method in serverInterface to parse the
string message to protocol buffer message to Server.

Below is how the clientInterface call the serverInterface to send out
protobuf message:

@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
    	
        //connect string will be received here
    	String requestMessage =(String) e.getMessage();
    	System.out.println("\n-->messageReceived("+this+"):server receive
"+requestMessage.length()+" bytes.\n"+requestMessage);

    	serverInterface client = new serverInterface ();
    	client.SendMessage(requestMessage);
    	

    }

which on serverInterface side will handle the call:

public void SendMessage(String receivedMessage) {
    	
    	if(receivedMessage.equalsIgnoreCase("connect")) {
    		
    		Message.Builder builder = Message.newBuilder();
          
    		builder.setMessageCode(
          			MessageCode.newBuilder().
          			setMessageId(MessageId.valueOf("CONNECT")).
          			setMessageTypeId(MessageTypeId.valueOf("TYPE_NOTHING"))
          		)
          		.setMessageContent(
          			MessageContent.newBuilder().
          			setRequestId(generateRequestId()).
          			setCsIdentificationNumber(1122334455)
          		);
        
    		Message message = builder.build();
          
                ChannelFuture lastWriteFuture = null;
            
    		lastWriteFuture = currentChannel.write(message);
    		
    	}
    }

Is this approach correct, because I can't get this part successfully done.

thanks in advance.
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Failed-to-build-a-middleman-to-pass-connection-between-a-server-and-a-client-tp5930926p5931002.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list