Esempio n. 1
0
        public bool Equals(SaveFileVC other)
        {
            if (other == null)
            {
                return(false);
            }

            return(SimpleVars.Equals(other.SimpleVars) &&
                   Scripts.Equals(other.Scripts) &&
                   PedPool.Equals(other.PedPool) &&
                   Garages.Equals(other.Garages) &&
                   GameLogic.Equals(other.GameLogic) &&
                   Vehicles.Equals(other.Vehicles) &&
                   Objects.Equals(other.Objects) &&
                   Paths.Equals(other.Paths) &&
                   Cranes.Equals(other.Cranes) &&
                   Pickups.Equals(other.Pickups) &&
                   PhoneInfo.Equals(other.PhoneInfo) &&
                   RestartPoints.Equals(other.RestartPoints) &&
                   RadarBlips.Equals(other.RadarBlips) &&
                   Zones.Equals(other.Zones) &&
                   Gangs.Equals(other.Gangs) &&
                   CarGenerators.Equals(other.CarGenerators) &&
                   ParticleObjects.Equals(other.ParticleObjects) &&
                   AudioScriptObjects.Equals(other.AudioScriptObjects) &&
                   ScriptPaths.Equals(other.ScriptPaths) &&
                   PlayerInfo.Equals(other.PlayerInfo) &&
                   Stats.Equals(other.Stats) &&
                   SetPieces.Equals(other.SetPieces) &&
                   Streaming.Equals(other.Streaming) &&
                   PedTypeInfo.Equals(other.PedTypeInfo));
        }
Esempio n. 2
0
    public World(
        IGameInstance gameInstance,
        Streaming sharedStreaming,
        WorldChunkComponent chunkComponent,
        Transform sceneGroup,
        GameObject defaultActorPrefab,
        GetObjectPoolRootDelegate getStaticPoolRoot,
        GetObjectPoolRootDelegate getTransientPoolRoot,
        SerializableObjectFactory objectFactory,
        INetDriver netDriver,
        NetMsgFactory netMsgFactory
        )
    {
        this.gameInstance      = gameInstance;
        _sceneGroup            = sceneGroup;
        _netDriver             = netDriver;
        _rpcReferenceCollector = new RPCObjectReferenceCollector(this);
        _objectFactory         = objectFactory;
        _netMsgFactory         = netMsgFactory;
        _getStaticPoolRoot     = getStaticPoolRoot;
        _getTransientPoolRoot  = getTransientPoolRoot;
        _defaultActorPrefab    = defaultActorPrefab;

        CacheNetworkDispatchMethods();

        _netArchiveBytes = new byte[MAX_RELIABLE_MESSAGE_SIZE];
        _netArchive      = new NetMsgArchive(_netArchiveBytes);
        _nextNetID       = 0;

        _worldStreaming       = sharedStreaming ?? new Streaming(chunkComponent, CreateGenVoxelsJob, MMapChunkData, WriteChunkData);
        _sharedWorldStreaming = sharedStreaming != null;
    }
Esempio n. 3
0
        public static InvocationRequest Stream(CancellationToken cancellationToken, Type resultType, string invocationId, ILoggerFactory loggerFactory, out ReadableChannel <object> result)
        {
            var req = new Streaming(cancellationToken, resultType, invocationId, loggerFactory);

            result = req.Result;
            return(req);
        }
        public async Task ListAvailableFilesWithOneHugeCall()
        {
            // The files are retrieved paginated, so if you want to retrieve all the files, you have two options:
            //     1) Do only one call with a huge page size.
            //     2) Do several calls with more manageable page size.
            // Depending on your requirements, you can choose between any of theses options.
            //
            // In this example it's shown how to do the first option: do only one call to retrieve all the available files.

            #region Custom parameters

            var tenantId = "MyTenantId"; // Only necessary for multi-tenant token.

            #endregion

            _output.WriteTittle("Executing Streaming.SDK example: List available files with one call");

            // Configure the list.
            var pagination = new Pagination
            {
                PageIndex = 0,
                PageSize  = 1000 // Maximum value. If you have more files than this amount, you will need to use the second option instead.
            };

            // List the files.
            var listResult = await Streaming.GetAvailableFilesAsync(pagination, tenantId : tenantId);

            Assert.IsType <PaginatedItems <FileInfo> >(listResult);

            // Print the result.
            _output.WriteLine("Available files:");
            _output.WriteJsonPaginatedItemsWithoutData(listResult);
        }
        public async void UploadOneFile()
        {
            // To upload a file you need to provide the path of the file and the BusinessType where it's going to be uploaded.
            // Also, if you have a multitenant-token, the tenantId needs to be provided.

            #region Custom parameters

            var tenantId       = "MyTenantId"; // Only necessary for multi-tenant token.
            var businessTypeId = 0;            // Use the desired businessType.

            #endregion

            _output.WriteTittle("Executing Streaming.SDK example: Upload one file by Stream");

            // Configure the file that is going to be uploaded.
            var fileContent = "Cats have contributed to the extinction of 33 different species. Humans might be the next ones.";
            var ms          = new MemoryStream(Encoding.UTF8.GetBytes(fileContent));

            var request = new FileUploadRequest
            {
                Name           = "testStreamFile.txt",
                BusinessTypeId = businessTypeId
            };

            // Upload the file.
            var uploadResult = await Streaming.UploadFileAsync(request, ms, tenantId : tenantId);

            Assert.IsType <FileUploadInfo>(uploadResult);
            Assert.Equal(request.Name, uploadResult.Name);
            Assert.Equal(ms.Length, uploadResult.Size);

            // Print the result.
            _output.WriteLine("File was uploaded:");
            _output.WriteJson(uploadResult);
        }
    public IEnumerator ManageFrame(bool important)
    {
        RenderTexture.active = rendTexture;
        virtuCamera.Render();

        streaming.ReadPixels(new Rect(0, 0, width, height), 0, 0, false);
        streaming.Apply();

        RenderTexture.active = null;

        yield return(null);

        string frame = Convert.ToBase64String(streaming.EncodeToJPG(quality));

        Vector3 rot = cameraTransform.localEulerAngles;

        Thread ts = new Thread(new ThreadStart(() => {
            Streaming message             = new Streaming();
            message.important             = important;
            message.data                  = new Data();
            message.data.frame            = "data:image/jpg; base64," + frame;
            message.data.width            = width;
            message.data.height           = height;
            message.data.parameters       = new CustomParams();
            message.data.parameters.value = new CustomValues(rot);

            WebSocketManager.instance.SendMessageWeb(JsonUtility.ToJson(message).Replace("parameters", "params"));
        }));

        ts.Start();
    }
Esempio n. 7
0
    protected virtual void Dispose(bool disposing)
    {
        _netArchive.Dispose();
        _netArchive = null;
        _taskQueue.Clear();
        _loadingQueue.Clear();

        for (int i = 0; i < _actors.Count; ++i)
        {
            var actor = _actors[i];
            actor.Dispose();
            actor.internal_ClearReplicators();
        }

        _actors.Clear();
        _replicatedActors.Clear();
        _replicatedObjects.Clear();
        _travelActors = null;
        spawnTags     = null;

        if (!_sharedWorldStreaming)
        {
            _worldStreaming.Dispose();
            _worldStreaming = null;
        }
    }
        public void GetStream_AnonymousData_CorrectRequestProvider(
            [Frozen] Mock<IListener> listner,
            [Frozen] Mock<IRequestAuthorizer> authorizer,
            Mock<IFilterQuery> query,
            Streaming sut,
            HttpRequestMessage request,
            List<string> data)
        {
            //Arrange
            Func<HttpRequestMessage> requestProviderArgument = null;
            authorizer.Setup(a => a.AuthorizeRequest(It.IsAny<HttpRequestMessage>())).Returns(request);
            query.Setup(a => a.GetRequest()).Returns(request);
            listner.Setup(a => a.Listen(It.IsAny<Func<HttpRequestMessage>>(), It.IsAny<Action<string>>()))
                .Callback((Func<HttpRequestMessage> requestProvider, Action<string> processRequest) =>
                {
                    requestProviderArgument = requestProvider;
                });

            //Act
            var observable = sut.GetStream(query.Object);
            observable.Subscribe(a => {});
            var result = requestProviderArgument();

            //Assert
            result.Should().Be(request);
            query.Verify(a => a.GetRequest(), Times.Once);
            authorizer.Verify(a => a.AuthorizeRequest(request), Times.Once);
        }
Esempio n. 9
0
        public ActionResult Create([Bind(Include = "Id,Duracao,Tipo,Nome,Descricao,Preco,CategoriaId")] Streaming streaming, HttpPostedFileBase imagem, HttpPostedFileBase conteudo)
        {
            streaming.Tipo          = m_tipoMidia;
            streaming.TipoStreaming = m_tipoStreaming;
            streaming.AutorId       = new LoginViewModel().Buscar(User.Identity.Name).Id;
            if (imagem != null && imagem.ContentLength > 0)
            {
                streaming.Imagem       = new ArquivoBinario();
                streaming.Imagem.Bytes = new byte[imagem.ContentLength];
                imagem.InputStream.Read(streaming.Imagem.Bytes, 0, imagem.ContentLength);
            }

            if (conteudo != null && conteudo.ContentLength > 0)
            {
                streaming.Conteudo       = new ArquivoBinario();
                streaming.Conteudo.Bytes = new byte[conteudo.ContentLength];
                conteudo.InputStream.Read(streaming.Conteudo.Bytes, 0, conteudo.ContentLength);
            }

            if (ModelState.IsValid)
            {
                db.Streamings.Add(streaming);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(streaming));
        }
Esempio n. 10
0
        public async Task DownloadOneFileAndSaveItInFileSystem()
        {
            #region Custom parameters

            var tenantId = "MyTenantId"; // Only necessary for multi-tenant token.

            #endregion

            _output.WriteTittle("Executing Streaming.SDK example: Download one file and save the content in a file system");

            // First you need a valid file ID so you can download it.
            // If you already know the ID of an uploaded file, you can use, instead, that ID.
            var fileInfo = GetRandomUploadedFile(tenantId);
            var fileId   = fileInfo.FileId.ToString();

            var filePath = Path.Combine(FilesBaseDirectory, "downloadedFile.txt");
            using (var fs = new FileStream(filePath, FileMode.Create))
            {
                await Streaming.DownloadFileAsync(fileId, fs, tenantId : tenantId);

                Assert.Equal(fileInfo.FileSize, fs.Length);
                Assert.True(File.Exists(filePath), $"File was not downloaded correctly to {filePath}");
                _output.WriteLine($"File <{fileId}> downloaded at {filePath}");
            }
        }
Esempio n. 11
0
        public async Task DownloadOneFile()
        {
            #region Custom parameters

            var tenantId = "MyTenantId"; // Only necessary for multi-tenant token.

            #endregion

            _output.WriteTittle("Executing Streaming.SDK example: Download one file");

            // First you need a valid file ID so you can download it.
            // If you already know the ID of an uploaded file, you can use, instead, that ID.
            var fileInfo = GetRandomUploadedFile(tenantId);
            var fileId   = fileInfo.FileId.ToString();

            using (var ms = new MemoryStream())
            {
                //optional token source to cancel operations after some milliseconds:
                var tokenSource = new CancellationTokenSource();
                tokenSource.CancelAfter(30000);

                await Streaming.DownloadFileAsync(fileId, ms, tenantId : tenantId, tokenSource.Token);

                Assert.Equal(fileInfo.FileSize, ms.Length);
                _output.WriteLine($"File <{fileId}>. Content downloaded.");
            }
        }
Esempio n. 12
0
        public ActionResult DeleteConfirmed(int id)
        {
            Streaming streaming = db.Streamings.Find(id);

            db.Streamings.Remove(streaming);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 13
0
    public static InvocationRequest Stream(CancellationToken cancellationToken, Type resultType, string invocationId,
                                           ILoggerFactory loggerFactory, HubConnection hubConnection, out ChannelReader <object?> result)
    {
        var req = new Streaming(cancellationToken, resultType, invocationId, loggerFactory, hubConnection);

        result = req.Result;
        return(req);
    }
Esempio n. 14
0
 public void Dispose()
 {
     if (_stream != null)
     {
         _stream.Dispose();
         _stream = null;
     }
 }
Esempio n. 15
0
 public WallCrawl(SpiderManProfile profile) : base(profile)
 {
     // Request our thingys.
     Streaming.RequestAnimationDictionary("swimming@swim");
     Streaming.RequestAnimationDictionary("move_crouch_proto");
     Streaming.RequestAnimationDictionary("laddersbase");
     Streaming.RequestAnimationDictionary("move_m@brave");
     new Model("w_pi_pistol").Request();
 }
Esempio n. 16
0
        protected void Add(AttachmentData attachmentData)
        {
            if (!Streaming.IsModelInCdimage(attachmentData.Model))
            {
                return;
            }

            AttachmentDictionary.Add(attachmentData.Id, attachmentData);
        }
Esempio n. 17
0
 /// <summary>
 ///     The main constructor.
 /// </summary>
 public Melee(SpiderManProfile profile) : base(profile)
 {
     Streaming.RequestAnimationDictionary("melee@unarmed@streamed_core");
     Streaming.RequestAnimationDictionary("anim@mp_snowball");
     Streaming.RequestAnimationDictionary("random@arrests");
     Streaming.RequestAnimationDictionary("swimming@swim");
     Streaming.RequestAnimationDictionary("weapons@projectile@");
     Profile.LocalUser.BlockPermanentEvents = true;
 }
Esempio n. 18
0
 /// <summary>
 ///     The main constructor.
 /// </summary>
 public WebSwing(SpiderManProfile profile) : base(profile)
 {
     // Request our animations.
     Streaming.RequestAnimationDictionary("skydive@parachute@");
     Streaming.RequestAnimationDictionary("missrappel");
     Streaming.RequestAnimationDictionary("swimming@swim");
     Streaming.RequestAnimationDictionary("move_fall");
     new Model("bmx").Request();
 }
Esempio n. 19
0
 public TazerWebs(SpiderManProfile profile) :
     base(profile)
 {
     Abilities = new List <SpecialAbility>
     {
         new WebZip(profile),
         new WebSwing(profile)
     };
     Streaming.RequestAnimationDictionary("ragdoll@human");
 }
Esempio n. 20
0
 /// <summary>
 ///     The main ctor.
 /// </summary>
 public WebAttachments(SpiderManProfile profile) : base(profile)
 {
     Streaming.RequestAnimationDictionary("guard_reactions");
     Streaming.RequestAnimationDictionary("move_crouch_proto");
     Streaming.RequestAnimationDictionary("amb@code_human_wander_texting@male@base");
     Streaming.RequestAnimationDictionary("weapons@projectile@");
     Streaming.RequestAnimationDictionary("swimming@swim");
     new Model("bmx").Request();
     BackgroundThread.RegisterTick(UpdateAttachments);
 }
Esempio n. 21
0
    public static Stream GetDocumentStream(System.Xml.XmlDocument xmlDoc)
    {
        Stream output = new MemoryStream();

        if (xmlDoc != null)
        {
            xmlDoc.Save(output);
        }
        Streaming.Reset(ref output);
        return(output);
    }
Esempio n. 22
0
 public byte[] GetProductContent(string productId, string cultureCode)
 {
     try
     {
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.LoadXml(PrepareContent(productId, cultureCode, false, false, true, true));
         return(Streaming.StreamToByte(Streaming.GetDocumentStream(xmlDoc)));
     }
     catch (Exception exc)
     {
         return(Streaming.EmptyByte);
     }
 }
        public void Start()
        {
            Streaming.RequestAnimDict(Dictionary);

            while (!Streaming.HasAnimDictLoaded(Dictionary))
            {
                Invoker.Wait(0);
            }

            IsDictionaryLoaded = true;
            Audio.RequestAmbientAudioBank("VENDING_MACHINE", false, -1);
            Player.TaskPlayAnim(Dictionary, "PLYR_BUY_DRINK_PT1", 2f, -4f, -1, 1048576, 0, false, false, false);
        }
Esempio n. 24
0
        public MainWindow()
        {
            InitializeComponent();
            // SBConfig = ServiceBusConfig.CreateConfigs(sbPath);
            StreamingListView.ItemsSource = streamingValues;
            xWS.Content = $"Url  {wsPath}";

            socket = new MyWebSocket(wsPath);
            socket.Start();
            serviceBus     = new ServiceBus(ServiceBusConfig.Create(sbPath));
            streamingProd  = new Streaming(Streaming.Prod);
            streamingStage = new Streaming(Streaming.Stage);
        }
Esempio n. 25
0
 public ClientWorld(
     IGameInstance gameInstance,
     Streaming sharedStreaming,
     WorldChunkComponent chunkComponent,
     Transform sceneGroup,
     GameObject defaultActorPrefab,
     GetObjectPoolRootDelegate getStaticPoolRoot,
     GetObjectPoolRootDelegate getTransientPoolRoot,
     System.Reflection.Assembly[] assemblies,
     INetDriver driver
     ) : base(gameInstance, sharedStreaming, chunkComponent, sceneGroup, defaultActorPrefab, getStaticPoolRoot, getTransientPoolRoot, new ClientSerializableObjectFactory(assemblies), driver, new ClientNetMsgFactory(assemblies))
 {
 }
        public async void UploadOneFileByStreamFromFile()
        {
            // To upload a file you need to provide the path of the file and the BusinessType where it's going to be uploaded.
            // Also, if you have a multitenant-token, the tenantId needs to be provided.

            #region Custom parameters

            var tenantId       = "MyTenantId"; // Only necessary for multi-tenant token.
            var businessTypeId = 0;            // Use the desired businessType.

            #endregion

            _output.WriteTittle("Executing Streaming.SDK example: Upload one file by Stream from file");

            // Configure the file that is going to be uploaded.
            var fileName = "testFile.txt";
            var filePath = Path.Combine(FilesBaseDirectory, "Data", fileName);

            // Read a file and store the content into the MemoryStream.
            // If you want to upload directly from the file, check the examples of FileApi.MFT.FileSystem.
            using (var ms = new MemoryStream())
            {
                using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    var bytes = new byte[file.Length];
                    file.Read(bytes, 0, (int)file.Length);
                    ms.Write(bytes, 0, (int)file.Length);

                    var request = new FileUploadRequest
                    {
                        Name           = "testStreamFile.txt",
                        BusinessTypeId = businessTypeId
                    };

                    // Reset the position of the memory stream.
                    ms.Position = 0;

                    // Upload the file.
                    var uploadResult = await Streaming.UploadFileAsync(request, ms, tenantId : tenantId);

                    Assert.IsType <FileUploadInfo>(uploadResult);
                    Assert.Equal(request.Name, uploadResult.Name);
                    Assert.Equal(ms.Length, uploadResult.Size);

                    // Print the result.
                    _output.WriteLine("File was uploaded:");
                    _output.WriteJson(uploadResult);
                }
            }
        }
Esempio n. 27
0
        // GET: Musicas/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Streaming streaming = db.Streamings.Find(id);

            if (streaming == null)
            {
                return(HttpNotFound());
            }
            return(View(streaming));
        }
Esempio n. 28
0
        private FileInfo GetRandomUploadedFile(string tenantId)
        {
            var filter             = "Status eq 'All'";
            var randomUploadedFile = Streaming.GetAvailableFilesAsync(filter: filter, tenantId: tenantId).Result.Data;

            if (!randomUploadedFile.Any())
            {
                throw new ArgumentOutOfRangeException(
                          $"No uploaded file for tenantId <{tenantId}>. Please, execute the UploadExamples tests before theses.");
            }

            return(randomUploadedFile
                   .ElementAt(_random.Next(randomUploadedFile.Count())));
        }
Esempio n. 29
0
 public ActionResult Edit([Bind(Include = "Id,Duracao,Tipo,Nome,Descricao,Preco,Imagem,Conteudo,CategoriaId")] Streaming streaming)
 {
     streaming.Tipo          = m_tipoMidia;
     streaming.TipoStreaming = m_tipoStreaming;
     streaming.AutorId       = db.Streamings.Where(x => x.Id == streaming.Id).AsNoTracking().FirstOrDefault().AutorId;
     if (ModelState.IsValid)
     {
         db.Entry(streaming).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Categorias = new CategoriaViewModel().DeterminarCategoriasViewBag(m_tipoMidia);
     return(View(streaming));
 }
Esempio n. 30
0
        // GET: Musicas/Edit/id
        public ActionResult Edit(int?id)
        {
            ViewBag.Categorias = new CategoriaViewModel().DeterminarCategoriasViewBag(m_tipoMidia);
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Streaming streaming = db.Streamings.Find(id);

            if (streaming == null)
            {
                return(HttpNotFound());
            }
            return(View(streaming));
        }
Esempio n. 31
0
        public async Task DownloadTwoFilesInParallel()
        {
            #region Custom parameters

            var tenantId = "MyTenantId"; // Only necessary for multi-tenant token.

            #endregion

            // As the call is asynchronous, it is possible to do several calls in parallel.

            _output.WriteTittle("Executing Streaming.SDK example: Download two files in parallel");

            // First you need a valid file ID so you can download it.
            // If you already know the ID of an uploaded file, you can use, instead, that ID.
            var fileInfoFirst = GetRandomUploadedFile(tenantId);
            var fileIdFirst   = fileInfoFirst.FileId.ToString();

            var fileInfoSecond = GetRandomUploadedFile(tenantId);
            var fileIdSecond   = fileInfoSecond.FileId.ToString();

            using (var msFirstFile = new MemoryStream())
                using (var msSecondFile = new MemoryStream())
                {
                    _output.WriteLine($"Downloading files <{fileIdFirst}> and <{fileIdSecond}>.");

                    var downloadTasks = new List <Task>
                    {
                        Streaming.DownloadFileAsync(fileIdFirst, msFirstFile, tenantId: tenantId),
                        Streaming.DownloadFileAsync(fileIdSecond, msSecondFile, tenantId: tenantId)
                    };

                    // Wait for the files to be downloaded and print the results.
                    // If you only care about all files being downloaded and not the order, you can use Task.WhenAll instead.
                    var firstDownloadedFile = await Task.WhenAny(downloadTasks);

                    downloadTasks.Remove(firstDownloadedFile);

                    Assert.True(fileInfoFirst.FileSize == msFirstFile.Length || fileInfoSecond.FileSize == msSecondFile.Length,
                                "The downloaded stream doesn't contain the uploaded content.");
                    _output.WriteLine($"File <{fileIdFirst}>. Content downloaded.");

                    await Task.WhenAny(downloadTasks);

                    Assert.True(fileInfoFirst.FileSize == msFirstFile.Length && fileInfoSecond.FileSize == msSecondFile.Length,
                                "The downloaded stream doesn't contain the uploaded content.");
                    _output.WriteLine($"File <{fileIdSecond}>. Content downloaded.");
                }
        }
        public void GetStream_AnonymousData_ExceptionPropagated(
            [Frozen] Mock<IListener> listner,
            IFilterQuery query,
            Streaming sut)
        {
            //Arrange
            listner.Setup(a => a.Listen(It.IsAny<Func<HttpRequestMessage>>(), It.IsAny<Action<string>>()))
                .Throws<WebException>();
            Exception propagatedException = null;

            //Act
            var observable = sut.GetStream(query);
            observable.Subscribe(a => { }, ex => propagatedException = ex);

            //Assert
            propagatedException.Should().NotBeNull();
            propagatedException.Should().BeOfType<WebException>();
        }
        public void GetStream_AnonymousData_CorrectObservable(
            [Frozen] Mock<IListener> listner,
            IFilterQuery query,
            Streaming sut,
            HttpRequestMessage request,
            List<string> data)
        {
            listner.Setup(a => a.Listen(It.IsAny<Func<HttpRequestMessage>>(), It.IsAny<Action<string>>()))
                .Returns((Func<HttpRequestMessage> requestProvider, Action<string> processRequest) =>
                {
                    data.ForEach(processRequest);
                    return new Task(() => { });
                });

            var observable = sut.GetStream(query);

            var resultData = new List<string>();
            observable.Subscribe(a => resultData.Add(a));
            resultData.ShouldAllBeEquivalentTo(data);
        }
Esempio n. 34
0
 private void DataSender_DoWork(object sender, DoWorkEventArgs e)
 {
     string platform=null;
     StatusStripStreamIcon.Visible = true;
     StatusStripStreamIcon.Text = "Connecting to server...";
     http_web_request = (HttpWebRequest)WebRequest.Create(ip_address);
     StatusStripStreamIcon.Text = "Gathering data...";
     byte[] data;
     post_data = "";
     post_data += "secret=" + secret_key;
     post_data += "&petname=" + server_petname;
     post_data += "&OS=Windows";
     post_data += "&email=" + contact_email;
     post_data += "&agent_version=" + Application.ProductVersion;
     post_data += "&company=" + CompanyName;
     post_data += "&host=" + server_host;
     string cpu_value_string = cpu_value.ToString();
     string cpu_value_free_string = (100 - cpu_value).ToString();
     string server_uptime_string = FormatTime(server_uptime_value);
     cpu_value_string = cpu_value_string.Replace(",", ".");
     cpu_value_free_string = cpu_value_free_string.Replace(",", ".");
     post_data += "&cpu=" + ToBase64("{\"cpu_used\": " + cpu_value_string + ", \"cpu_user\": 0, \"cpu_system\": " + cpu_value_string + ", \"cpu_free\": " + cpu_value_free_string + "}");
     post_data += "&server_uptime="+server_uptime_string;
     post_data += "&memory=" + ToBase64("{\"mem_used\": 0, \"mem_user\": 0, \"mem_system\": 0, \"mem_free\": 0}");
     post_data += "&loadavg=" + ToBase64("{\"load_one\": 0, \"load_five\": 0, \"load_fifteen\": 0}");
     if (operation_system_32_64bit == "32bit")
     {
         platform = "windows_32";
     }
     else if (operation_system_32_64bit == "64bit")
     {
         platform = "windows_64";
     }
     post_data += "&OS="+ToBase64("{\"version\": (\""+operation_system_version+"\",\""+operation_system_32_64bit+"\"),\"cpu_cores\": "+cpu_cores+",\"machine\": \""+cpu_32_64bit+"\",\"processor\": \""+cpu_architecture+"\",\"platform\": \""+platform+"\"}");
     post_data += "&windows_info=" +ToBase64("{\"battery_status\": "+battery_status+", \"design_capacity\": "+design_capacity+", \"estimated_charge_remaining\": "+battery_power_percent+",\"estimated_run_time\": "+estimated_run_time+",\"full_charge_capacity\": "+full_charge_capacity+",\"time_on_battery\": "+time_on_battery+",\"time_to_full_charge\": "+time_to_full_charge+"}");
     data = Encoding.UTF8.GetBytes(post_data);
     StatusStripStreamIcon.Text = "Creating request...";
     http_web_request.Method = "POST";
     http_web_request.ContentType = "application/x-www-form-urlencoded";
     http_web_request.ContentLength = data.Length;
     StatusStripStreamIcon.Text = "Sending data...";
     try
     {
         Stream sendingData = http_web_request.GetRequestStream();
         sendingData.Write(data, 0, data.Length);
         sendingData.Close();
         using (WebResponse response = http_web_request.GetResponse())
         {
             sendingData = response.GetResponseStream();
             StreamReader reader = new StreamReader(sendingData);
             string response_from_server = reader.ReadToEnd();
             streaming_old = streaming;
                 switch (response_from_server)
                 {
                     case "streaming off":
                         streaming = Streaming.Off;
                         break;
                     case "streaming on":
                         streaming = Streaming.On;
                         break;
                     case "stop":
                         if (mode == Mode.Expert)
                         {
                             if (mode == Mode.Expert)
                             {
                                 ShowNotify("Sending stopped", "Data sending has been stopped by server", ToolTipIcon.Warning);
                             }
                         }
                         SendingToggle();
                         break;
                     case "update":
                         ShowNotify("Update", "Agent is upgraded to the latest version",ToolTipIcon.Info);
                         Form updater_form=new Updater();
                         SendingToggle(true);
                         updater_form.ShowDialog();
                         Process.Start("Cloudiff updater.exe");
                         break;
             }
             reader.Close();
             sendingData.Close();
             response.Close();
         }
         StatusStripStreamIcon.Text = "Data send OK...";
     }
     catch (Exception exception)
     {
         WriteError(exception);
         if (mode == Mode.Expert)
         {
             ShowNotify("No route to host", "Cannot send data. Trying to connect...\nError: " + exception.Message, ToolTipIcon.Warning,2000);
         }
     }
     StatusStripStreamIcon.Visible = false;
 }