Re: [xSocket-develop] How to trigger onConnect method?
Status: Inactive
Brought to you by:
grro
|
From: Gregor R. <gre...@go...> - 2008-12-09 13:29:00
|
Hi,
the onConnect method will be called by xsocket (if implemented), after the
incoming client connection is established. This means if your flash-client
connects your server, the onConnect-Method will be called automatically.
Often the onConnect method is used to set connection properties (e.g. a bad
IP address -> connection.setWriteTransferRate) or to send a greeting message
to the client (e.g. smtp -> connection.write("220 mx0.gmx.net GMX
Mailservices ESMTP") )
Gregor
2008/12/9 <jun...@wp...>
> hi,
>
> My java application with xsocket server communicate with Flash client.
> Method onData works. But how to trigger onConnect method? It should be
> triggered when my Flash client connects, right? Do I have to send
> additional manually some kind of greetings message in order to trigger
> onConnnnect method?
>
> Hier is my code
>
> <Main.java>
>
> srv = new Server(8091, new xSocketDataHandler());
> srv.start();
>
> <xSocketDataHandler.java>
>
> package xsocketserver;
>
> import java.io.IOException;
> import java.nio.BufferUnderflowException;
> import java.nio.channels.ClosedChannelException;
> import org.xsocket.*;
> import org.xsocket.connection.*;
>
> public class xSocketDataHandler implements IDataHandler
>
>
> {
> public INonBlockingConnection nbc;
>
> public boolean onConnect(INonBlockingConnection nbc) throws IOException
> {
> System.out.println("Connected!!!!!");
> return true;
> }
>
> public boolean onDisconnect(INonBlockingConnection nbc) throws
> IOException {
> System.out.println("Disconected!!!!!!!!!!!!!!!!");
> return true;
> }
>
>
>
>
>
>
>
> public boolean onData(INonBlockingConnection nbc) throws IOException,
> BufferUnderflowException, ClosedChannelException,
> MaxReadSizeExceededException
> {
> try
> {
> String data = nbc.readStringByDelimiter("\0");
>
>
> System.out.println("Reciving Data");
>
>
> if(data.equalsIgnoreCase("SHUTDOWN"))
> Main.shutdownServer();
>
>
> }
> catch(Exception ex)
> {
> System.out.println(ex.getMessage());
> }
>
> return true;
> }
> }
>
> regards,
> sly
>
> ----------------------------------------------------
> Przyjdź za najlepiej ROCKUJĄCY "Sylwester z Sylwestrem"
> w Hotelu Nadmorskim w Gdyni - Kliknij:
>
> http://klik.wp.pl/?adr=http%3A%2F%2Fwww.nadmorski.pl%2Fsylwester_gdynia%2F&sid=579
>
>
>
>
> ------------------------------------------------------------------------------
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
> The future of the web can't happen without you. Join us at MIX09 to help
> pave the way to the Next Web now. Learn more and register at
>
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
> _______________________________________________
> xSocket-develop mailing list
> xSo...@li...
> https://lists.sourceforge.net/lists/listinfo/xsocket-develop
> |