[xSocket-develop] How to trigger onConnect method?
Status: Inactive
Brought to you by:
grro
|
From: <jun...@wp...> - 2008-12-09 12:04:40
|
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
|