Mike M a écrit :
These are the modifications that i have made in the chat example:
class Server
{
public static var clients = new List<ClientData>();
static function initClientApi( scnx : haxe.remoting.SocketConnection,
server : neko.net.RemotingServer ) {
trace("Client connected");
var c = new ClientData(scnx);
server.addObject("api",c);
}
static function onClientDisconnected( scnx ) {
trace("Client disconnected");
ClientData.ofConnection(scnx).leave();
}
static function onXml( cnx : haxe.remoting.SocketConnection, data :
String )
{
trace("a"+data);
cnx.getProtocol().socket.write("<cross-domain-policy><allow-access-from
domain=\"*\" /></cross-domain-policy>") ;
}
static function readClientMessage( cnx :
haxe.remoting.SocketConnection, buf : String, pos : Int, len : Int ) : {
msg : String, bytes : Int}
{
trace(buf);
return null;
}
static function clientMessage( cnx : haxe.remoting.SocketConnection,
msg : String )
{
trace( msg);
}
static function main() {
var s = new neko.net.ThreadRemotingServer();
s.initClientApi = initClientApi;
s.clientDisconnected = onClientDisconnected;
s.onXml=onXml;
s.readClientMessage = readClientMessage;
s.clientMessage=clientMessage;
s.run("localhost",1024);
}
}
And after many tests, i can say that i dont go in the onXml function and
i get of course "<policy-file-request/>" in readClientMessage
function... How is it possible ?
Because this is the implementation of readClientMessage that calls onXml ;)
If you want to handle XML using your own protocol, check in
readClientMessage that it starts with '<' and read the content up to \0
Best,
Nicolas
--
Neko : One VM to run them all
(http://nekovm.org)