Hello! I have a web application built in unity than opens a socket to a server. This works just fine, but when i try to convert this application to Flash, i get the following conversion errors: Code (csharp): Error building Player: Exception: Compiling SWF Failed: Loading configuration file C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\flashsupport\BuildTools\flex\frameworks\flex-config.xml E:\SocketFlashTest\Temp\StagingArea\Data\ConvertedDotNetCode\global\SocketManager_AsynchronousClient.as(125): col: 79 Error: Type was not found or was not a compile-time constant: IAsyncResult. public static function AsynchronousClient_ConnectCallback_IAsyncResult($ar: IAsyncResult): void { ^ E:\SocketFlashTest\Temp\StagingArea\Data\ConvertedDotNetCode\global\SocketManager_AsynchronousClient.as(141): col: 69 Error: Type was not found or was not a compile-time constant: Socket. public static function AsynchronousClient_Receive_Socket($client: Socket): void { ^ E:\SocketFlashTest\Temp\StagingArea\Data\ConvertedDotNetCode\global\SocketManager_AsynchronousClient.as(151): col: 79 Error: Type was not found or was not a compile-time constant: IAsyncResult. public static function AsynchronousClient_ReceiveCallback_IAsyncResult($ar: IAsyncResult): void { ^ E:\SocketFlashTest\Temp\StagingArea\Data\ConvertedDotNetCode\global\SocketManager_AsynchronousClient.as(194): col: 73 Error: Type was not found or was not a compile-time constant: Socket. public static function AsynchronousClient_Send_Socket_String($client: Socket, $data: String): void { ^ E:\SocketFlashTest\Temp\StagingArea\Data\ConvertedDotNetCode\global\SocketManager_AsynchronousClient.as(199): col: 76 Error: Type was not found or was not a compile-time constant: IAsyncResult. public static function AsynchronousClient_SendCallback_IAsyncResult($ar: IAsyncResult): void { ^ E:\SocketFlashTest\Temp\StagingArea\Data\ConvertedDotNetCode\global\SocketManager_StateObject.as(14): col: 39 Error: Type was not found or was not a compile-time constant: Socket. public var StateObject$workSocket$: Socket; ^ E:\SocketFlashTest\Temp\StagingArea\Data\ConvertedDotNetCode\global\SocketManager_StateObject.as(7): col: 27 Error: Definition System.Net.Sockets:Socket could not be found. import System.Net.Sockets.Socket; ^ Means this that sockets are not available on flash version? If they are, how should we use them so we do not get these errors? Thanks in advance!
Sockets are not support. Can't provide for the functionality that the Socket class has. Instead you can write your own C# glue layer on top of pure actionscript using the UnityEngine.FlashApi and the ability to compile in ActionScript in your project.
Here is a very basic example of how to implement sockets in AS3. There are only 3 classes in this example: TestRunner.cs - A MonoBehaviour residing on the camera in the scene. Creates a new ActionScriptSocket instance and requests to connect to the socket. This class also has a function to display the socket response (called from the AS3 class). ActionScriptSocket.as - Has functionality for connecting to and returning results from the socket. Will call a method on the TestRunner to display any connection results or errors. ActionScriptSocket.cs - A proxy script with the same public API as the ActionScript version. View attachment $Sockets.zip