Using ThreadRemotingServer and Flash 9 Clients

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Using ThreadRemotingServer and Flash 9 Clients

Geoffrey Hug
Hi all,

So I've started HaXe developpment 3 weeks ago and I got myself a working client/server multiplayer game locally.

It's a Neko server and the client is flash 9.

Now that it's finished, I would like to put it on my server but I'm encountering some issues.

When I try to connect via the web browser on my client page that embeds my SWF client, it stays blank.

I don't know why because even when I have no server running, I still get the basic drawings that do not require connection with the server on the local client.

This is the client's connection code :

function new()
    {   
        try
        {   
            var s = new XMLSocket();                                   

            s.addEventListener( Event.CONNECT, onConnect );          
       
            s.connect("localhost", 1024);                         
       
            var ctx = new Context();   
            ctx.addObject("client", this);                                   
           
            var scnx = haxe.remoting.SocketConnection.create( s, ctx );
            scnx.setErrorHandler( errorHandler );
           
            serverApi = new ServerApi(scnx.api);                           
        }
        catch( err : Dynamic )
        {
            trace(err);
        }

    }

I noticed that if I changed the line
s.connect("localhost", 1024);
to
s.connect("whatever", 1024);

Then the client would do the same thing even locally.

So I think this probably not very complicated and may be related to flash security. But I can't seem to figure out what I should do to make it work. Could someone explain simply enough how it works to get these working on a real client/server ?

This is the code of the ThreadRemotingServer in case it is helpful :

    private static function main()
    {
        var host = "http://192.168.0.132/";
        var domains = [host];
        var s = new neko.net.ThreadRemotingServer(domains);
        s.initClientApi = initClientApi;
        s.clientDisconnected = clientDisconnected;
        trace("Starting Tutti Frutti Server...");
        s.run("localhost", 1024);

    }

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using ThreadRemotingServer and Flash 9 Clients

Nicolas Cannasse
Le 22/07/2011 18:26, Geoffrey Hug a écrit :

> Hi all,
>
> So I've started HaXe developpment 3 weeks ago and I got myself a working
> client/server multiplayer game locally.
>
> It's a Neko server and the client is flash 9.
>
> Now that it's finished, I would like to put it on my server but I'm
> encountering some issues.
>
> When I try to connect via the web browser on my client page that embeds
> my SWF client, it stays blank.

Connections with sockets are quite security-restricted in Flash. Read
the AS3 reference documention for the socket class.

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using ThreadRemotingServer and Flash 9 Clients

Geoffrey Hug
Connections with sockets are quite security-restricted in Flash. Read the AS3 reference documention for the socket class.

Nicolas

--
haXe - an open source web programming language
http://haxe.org

I looked into it and put a crossdomain.xml file with this code inside :

<?xml version="1.0"?>
<cross-domain-policy>
    <site-control permitted-cross-domain-policies="master-only" />
    <allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>

I can see the client connect to the server but it's immediately disconnected.

I don't know what's going wrong here, if I use the client on the same machine as the server it works fine when it is put as trusted in the security settings manager.
Although when not trusted I get a 2010 error which I think is not really related to my problem.

The same client is also hosted on our web server and when I go on the page I only get a blank page with no error.
On the neko server I can see that the client connected and was immediately disconnected.

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using ThreadRemotingServer and Flash 9 Clients

Jan_Flanders


On Mon, Jul 25, 2011 at 2:52 PM, Geoffrey Hug <[hidden email]> wrote:
Connections with sockets are quite security-restricted in Flash. Read the AS3 reference documention for the socket class.

Nicolas

--
haXe - an open source web programming language
http://haxe.org

I looked into it and put a crossdomain.xml file with this code inside :

<?xml version="1.0"?>
<cross-domain-policy>
    <site-control permitted-cross-domain-policies="master-only" />
    <allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>

A crossdomain.xml file will not work for connections made with the Socket or XMLSocket class. The contents of that xml file needs to be served by 'a crossdomain policy file socket server' and not through an http request.

Jan


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using ThreadRemotingServer and Flash 9 Clients

clemos
Hi,

Yeah I do remember this one too, was very tricky to track down:
http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html

To put it simply, Flash Player will send your socket server this
string : <policy-file-request/>
At this time, your server must respond with the content of your policy file.
I don't have the code any more, but I remember it was not too
difficult to modify ThreadRemotingServer to make it behave like that.

Cheers,
Clément

On Mon, Jul 25, 2011 at 3:29 PM, Jan Flanders <[hidden email]> wrote:

>
>
> On Mon, Jul 25, 2011 at 2:52 PM, Geoffrey Hug <[hidden email]> wrote:
>>
>> Connections with sockets are quite security-restricted in Flash. Read the
>> AS3 reference documention for the socket class.
>>>
>>> Nicolas
>>>
>>> --
>>> haXe - an open source web programming language
>>> http://haxe.org
>>
>> I looked into it and put a crossdomain.xml file with this code inside :
>>
>> <?xml version="1.0"?>
>> <cross-domain-policy>
>>     <site-control permitted-cross-domain-policies="master-only" />
>>     <allow-access-from domain="*" to-ports="*" />
>> </cross-domain-policy>
>>
> A crossdomain.xml file will not work for connections made with the Socket or
> XMLSocket class. The contents of that xml file needs to be served by 'a
> crossdomain policy file socket server' and not through an http request.
>
> Jan
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using ThreadRemotingServer and Flash 9 Clients

tong-2
On 07/25/2011 03:48 PM, clemos wrote:

> Hi,
>
> Yeah I do remember this one too, was very tricky to track down:
> http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html
>
> To put it simply, Flash Player will send your socket server this
> string : <policy-file-request/>
> At this time, your server must respond with the content of your policy file.
> I don't have the code any more, but I remember it was not too
> difficult to modify ThreadRemotingServer to make it behave like that.
>
> Cheers,
> Clément
>
> On Mon, Jul 25, 2011 at 3:29 PM, Jan Flanders <[hidden email]> wrote:
>>
>> On Mon, Jul 25, 2011 at 2:52 PM, Geoffrey Hug <[hidden email]> wrote:
>>> Connections with sockets are quite security-restricted in Flash. Read the
>>> AS3 reference documention for the socket class.
>>>> Nicolas
>>>>
>>>> --
>>>> haXe - an open source web programming language
>>>> http://haxe.org
>>> I looked into it and put a crossdomain.xml file with this code inside :
>>>
>>> <?xml version="1.0"?>
>>> <cross-domain-policy>
>>>     <site-control permitted-cross-domain-policies="master-only" />
>>>     <allow-access-from domain="*" to-ports="*" />
>>> </cross-domain-policy>
>>>
>> A crossdomain.xml file will not work for connections made with the Socket or
>> XMLSocket class. The contents of that xml file needs to be served by 'a
>> crossdomain policy file socket server' and not through an http request.
>>
>> Jan
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
https://github.com/tong/hxmpp/blob/master/util/FlashPolicyServer.hx
.. a crossplatform flash policy server (neko/cpp/air/nodejs)

--
[) | 5 |< † |2 3 3 - http://disktree.net


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using ThreadRemotingServer and Flash 9 Clients

Geoffrey Hug
Thank you very much for all your answers, I finally made it work :)

We actually had another project like this one running with a nodeJS policy server.

Maybe having it integrated with the ThreadRemotingServer could be interesting too.

2011/7/25 tong <[hidden email]>
On 07/25/2011 03:48 PM, clemos wrote:
> Hi,
>
> Yeah I do remember this one too, was very tricky to track down:
> http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html
>
> To put it simply, Flash Player will send your socket server this
> string : <policy-file-request/>
> At this time, your server must respond with the content of your policy file.
> I don't have the code any more, but I remember it was not too
> difficult to modify ThreadRemotingServer to make it behave like that.
>
> Cheers,
> Clément
>
> On Mon, Jul 25, 2011 at 3:29 PM, Jan Flanders <[hidden email]> wrote:
>>
>> On Mon, Jul 25, 2011 at 2:52 PM, Geoffrey Hug <[hidden email]> wrote:
>>> Connections with sockets are quite security-restricted in Flash. Read the
>>> AS3 reference documention for the socket class.
>>>> Nicolas
>>>>
>>>> --
>>>> haXe - an open source web programming language
>>>> http://haxe.org
>>> I looked into it and put a crossdomain.xml file with this code inside :
>>>
>>> <?xml version="1.0"?>
>>> <cross-domain-policy>
>>>     <site-control permitted-cross-domain-policies="master-only" />
>>>     <allow-access-from domain="*" to-ports="*" />
>>> </cross-domain-policy>
>>>
>> A crossdomain.xml file will not work for connections made with the Socket or
>> XMLSocket class. The contents of that xml file needs to be served by 'a
>> crossdomain policy file socket server' and not through an http request.
>>
>> Jan
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
https://github.com/tong/hxmpp/blob/master/util/FlashPolicyServer.hx
.. a crossplatform flash policy server (neko/cpp/air/nodejs)

--
[) | 5 |< † |2 3 3 - http://disktree.net


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using ThreadRemotingServer and Flash 9 Clients

Marcelo de Moraes Serpa
Hey Geoffrey, I'm about to start a multiplayer project with haXe as well, could you share your experience with the language / platform? Did you enjoy creating, did the language helped you model the game better? What was your overall experience?

Thanks!

Marcelo.

On Mon, Jul 25, 2011 at 9:12 AM, Geoffrey Hug <[hidden email]> wrote:
Thank you very much for all your answers, I finally made it work :)

We actually had another project like this one running with a nodeJS policy server.

Maybe having it integrated with the ThreadRemotingServer could be interesting too.


2011/7/25 tong <[hidden email]>
On 07/25/2011 03:48 PM, clemos wrote:
> Hi,
>
> Yeah I do remember this one too, was very tricky to track down:
> http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html
>
> To put it simply, Flash Player will send your socket server this
> string : <policy-file-request/>
> At this time, your server must respond with the content of your policy file.
> I don't have the code any more, but I remember it was not too
> difficult to modify ThreadRemotingServer to make it behave like that.
>
> Cheers,
> Clément
>
> On Mon, Jul 25, 2011 at 3:29 PM, Jan Flanders <[hidden email]> wrote:
>>
>> On Mon, Jul 25, 2011 at 2:52 PM, Geoffrey Hug <[hidden email]> wrote:
>>> Connections with sockets are quite security-restricted in Flash. Read the
>>> AS3 reference documention for the socket class.
>>>> Nicolas
>>>>
>>>> --
>>>> haXe - an open source web programming language
>>>> http://haxe.org
>>> I looked into it and put a crossdomain.xml file with this code inside :
>>>
>>> <?xml version="1.0"?>
>>> <cross-domain-policy>
>>>     <site-control permitted-cross-domain-policies="master-only" />
>>>     <allow-access-from domain="*" to-ports="*" />
>>> </cross-domain-policy>
>>>
>> A crossdomain.xml file will not work for connections made with the Socket or
>> XMLSocket class. The contents of that xml file needs to be served by 'a
>> crossdomain policy file socket server' and not through an http request.
>>
>> Jan
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
https://github.com/tong/hxmpp/blob/master/util/FlashPolicyServer.hx
.. a crossplatform flash policy server (neko/cpp/air/nodejs)

--
[) | 5 |< † |2 3 3 - http://disktree.net


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using ThreadRemotingServer and Flash 9 Clients

Geoffrey Hug
Sure, although I was a real beginner at HaXe when I started this project but it felt like the language is pretty intuitive after a little while and I found myself doing things faster than in other languages even if I needed to research many things about the Flash platform which I wasn't very familiar with.

Also I was very excited about the language so may be this speeded things up. Anyway I had a good experience on this project.

I think the possibilities that the ThreadRemotingServer offers is really great and helps a lot for multiplayer game development.
Being able to call the client's methods server side and vice versa is really helpful. Again I'm not very experienced in multiplayer games ( this is actually my first ) but I think this a unique feature of Haxe and I don't know how it's done otherwise but I guess it's a lot harder.

And yes I enjoyed creating, hardest part of course was to start and understand how the remoting works exactly and also some flash security issues. But in the end it took 3 weeks to get the game done ( I'm the only developer on this project ) and I'm pretty satisfied with the result because it is very fluid.

We still need to do some testing on a larger scale, to see how the neko server will handle the load.

By the way, I'm wondering how I could make something that would simulate a lot of clients connecting and playing together.

2011/7/25 Marcelo de Moraes Serpa <[hidden email]>

Hey Geoffrey, I'm about to start a multiplayer project with haXe as well, could you share your experience with the language / platform? Did you enjoy creating, did the language helped you model the game better? What was your overall experience?

Thanks!

Marcelo.


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Using ThreadRemotingServer and Flash 9 Clients

Raul Ferriz
Hello!

A short question. Is it possible to develop a haxe game with multiplayer
running on android?

--
haXe - an open source web programming language
http://haxe.org