Exemplo n.º 1
0
        public Task TryConnect(int port)
        {
            socketContext      = new SocketContext();
            clientConnectedTCS = new TaskCompletionSource <bool>();

            socketContext.Connected = (clientSocketContext) =>
            {
                // Create an effect compiler per connection
                var effectCompiler = new EffectCompiler();

                var tempFilename = Path.GetTempFileName();
                var fileStream   = new FileStream(tempFilename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);

                // TODO: Properly close the file, and choose where to copy/move it?
                var recordedEffectCompile = new EffectLogStore(fileStream);

                // TODO: This should come from an "init" packet
                effectCompiler.SourceDirectories.Add(EffectCompilerBase.DefaultSourceShaderFolder);

                // Make a VFS that will access remotely the DatabaseFileProvider
                // TODO: Is that how we really want to do that in the future?
                var networkVFS = new NetworkVirtualFileProvider(clientSocketContext, "/asset");
                VirtualFileSystem.RegisterProvider(networkVFS);
                effectCompiler.FileProvider = networkVFS;

                clientSocketContext.AddPacketHandler <ShaderCompilerRequest>((packet) => ShaderCompilerRequestHandler(clientSocketContext, recordedEffectCompile, effectCompiler, packet));

                clientConnectedTCS.TrySetResult(true);
            };

            // Wait for a connection to be possible on adb forwarded port
            var clientDone = socketContext.StartClient(IPAddress.Loopback, port);

            return(clientDone);
        }
Exemplo n.º 2
0
        public Task Connect(int port)
        {
            socketContext.Connected = context =>
            {
                // Register network VFS
                NetworkVirtualFileProvider.RegisterServer(context);

                socketContextClientTCS.TrySetResult(context);
            };

            socketContext.StartServer(port);

            // Wait for server to connect to us (as a Task)
            return(socketContextClientTCS.Task);
        }
Exemplo n.º 3
0
        public async Task <SocketMessageLayer> Connect(Guid?packageId, CancellationToken cancellationToken)
        {
            var url = string.Format("/service/{0}/SiliconStudio.Xenko.EffectCompilerServer.exe", XenkoVersion.NuGetVersion);

            if (packageId.HasValue)
            {
                url += string.Format("?packageid={0}", packageId.Value);
            }

            var socketContext = await RouterClient.RequestServer(url, cancellationToken);

            var socketMessageLayer = new SocketMessageLayer(socketContext, false);

            // Register network VFS
            NetworkVirtualFileProvider.RegisterServer(socketMessageLayer);

            Task.Run(() => socketMessageLayer.MessageLoop());

            return(socketMessageLayer);
        }
Exemplo n.º 4
0
        public async Task <SocketMessageLayer> Connect(string packageName, CancellationToken cancellationToken)
        {
            var url = $"/service/Xenko.EffectCompilerServer/{XenkoVersion.NuGetVersion}/Xenko.EffectCompilerServer.exe";

            if (packageName != null)
            {
                url += string.Format("?packagename={0}", packageName);
            }

            var socketContext = await RouterClient.RequestServer(url, cancellationToken);

            var socketMessageLayer = new SocketMessageLayer(socketContext, false);

            // Register network VFS
            NetworkVirtualFileProvider.RegisterServer(socketMessageLayer);

            Task.Run(() => socketMessageLayer.MessageLoop());

            return(socketMessageLayer);
        }
Exemplo n.º 5
0
        public async Task <SocketMessageLayer> Connect(Guid?packageId)
        {
            var url = string.Format("/service/{0}/SiliconStudio.Paradox.EffectCompilerServer.exe", ParadoxVersion.CurrentAsText);

            if (packageId.HasValue)
            {
                url += string.Format("?packageid={0}", packageId.Value);
            }

            var socketContext = await RouterClient.RequestServer(url);

            var socketMessageLayer = new SocketMessageLayer(socketContext, false);

            // Register network VFS
            NetworkVirtualFileProvider.RegisterServer(socketMessageLayer);

            Task.Run(() => socketMessageLayer.MessageLoop());

            return(socketMessageLayer);
        }
Exemplo n.º 6
0
        /// <inheritdoc/>
        protected override async void HandleClient(SimpleSocket clientSocket, string url)
        {
            string[] urlSegments;
            string   urlParameters;

            RouterHelper.ParseUrl(url, out urlSegments, out urlParameters);
            var parameters = RouterHelper.ParseQueryString(urlParameters);
            var mode       = parameters["mode"];

            // We accept everything
            await AcceptConnection(clientSocket);

            var socketMessageLayer = new SocketMessageLayer(clientSocket, true);

            Guid?packageId = null;

            {
                Guid packageIdParsed;
                if (Guid.TryParse(parameters["packageid"], out packageIdParsed))
                {
                    packageId = packageIdParsed;
                }
            }

            if (mode == "gamestudio")
            {
                Console.WriteLine(@"GameStudio mode started!");

                if (!packageId.HasValue)
                {
                    return;
                }

                lock (gameStudioPerPackageId)
                {
                    gameStudioPerPackageId[packageId.Value] = socketMessageLayer;
                }
            }
            else
            {
                // Create an effect compiler per connection
                var effectCompiler = new EffectCompiler();

                Console.WriteLine(@"Client connected");

                // TODO: This should come from an "init" packet
                effectCompiler.SourceDirectories.Add(EffectCompilerBase.DefaultSourceShaderFolder);

                // Make a VFS that will access remotely the DatabaseFileProvider
                // TODO: Is that how we really want to do that in the future?
                var networkVFS = new NetworkVirtualFileProvider(socketMessageLayer, "/asset");
                VirtualFileSystem.RegisterProvider(networkVFS);
                effectCompiler.FileProvider = networkVFS;

                socketMessageLayer.AddPacketHandler <RemoteEffectCompilerEffectRequest>(packet => ShaderCompilerRequestHandler(socketMessageLayer, effectCompiler, packet));

                socketMessageLayer.AddPacketHandler <RemoteEffectCompilerEffectRequested>(packet =>
                {
                    if (!packageId.HasValue)
                    {
                        return;
                    }

                    SocketMessageLayer gameStudio;
                    lock (gameStudioPerPackageId)
                    {
                        if (!gameStudioPerPackageId.TryGetValue(packageId.Value, out gameStudio))
                        {
                            return;
                        }
                    }

                    // Forward to game studio
                    gameStudio.Send(packet);
                });
            }

            Task.Run(() => socketMessageLayer.MessageLoop());
        }