I was able to create a C # server that sends files to AS3 (AIR) clients using sockets . On the AS3 side, I use the flash.net.Socket library to receive data over TCP .
Here's how it works:
-> I turn on my server and it listens to clients (plus I can create a list of connected devices),
-> I turn on my client and automatically receives data;
The trigger event for receiving data is executed on the client, that is, I just turn on the server and when the client turns on, it receives data, causing these events:
socket.addEventListener(Event.CONNECT, onConnect); -> to connect to the server socket.addEventListener(Event.SOCKET_DATA, onDataArrival); -> to receive the data
Now I want to do something else. I do not want to run it on the client, I want the server to do this, i.e. I want to enable my client and on the server put in which client will receive the data.
So why am I trying to make a client a client / server? Good, because my server is one machine, and my clients are XXX mobile devices that connect the server, and this is my approach to this.
So, considering what I just said, I managed to create my AS3 client / server application, which works the same way as I do, using the flash.net.ServerSocket library.
First, I set the client to listen:
serverSocket.bind(portNumber, "10.1.1.212"); serverSocket.addEventListener(ServerSocketConnectEvent.CONNECT, onConnectServer); serverSocket.listen();
And then I get the data using flash.net.Socket Event.SOCKET_DATA
And that is pretty much the case. It works the way I want. However, flash.net.ServerSocket not compatible with mobile devices, but ...
So, here is my problem: I need to send files from a C # server (which must listen on clients so that I can create a list of connected devices) for AS3 clients (AIR), but I have to determine which client receives data on the server, and the clients should be ready to accept this data at any time, so listen, but there are a lot of them, so I consider them customers.
And my question is: is there a way to get the client to listen for incoming connections and fire an event when this happens without using Server Socket in AS3?
In addition, if you have a different approach to achieving my goal without using C # server โ AS3 client / server logic, please feel free to, in your opinion.