예제 #1
0
        /// <summary>
        /// The register load string.
        /// </summary>
        protected void RegisterLoadString()
        {
            this.PageContext.PageElements.RegisterJQuery();

            var message = this.PageContext.LoadMessage.GetMessage();

            if (message == null)
            {
                return;
            }

            /*if (ScriptManager.GetCurrent(this.ForumControl.Page) == null)
             * {
             *  return;
             * }*/

            // Get the clean JS string.
            message.Message = LoadMessage.CleanJsString(message.Message);

            if (string.IsNullOrEmpty(message.Message))
            {
                return;
            }

            this.PageContext.PageElements.RegisterJsBlockStartup(
                this.ForumControl.Page,
                "modalNotification",
                "var fpModal = function() {{ {2}('{0}', '{1}'); Sys.Application.remove_load(fpModal); }}; Sys.Application.add_load(fpModal);"
                .FormatWith(message.Message, message.MessageType.ToString().ToLower(), this._errorPopup.ShowModalFunction));
        }
예제 #2
0
        private void handleData(byte[] data, string port)
        {
            try {
                MessageBase msg = JsonSerializer.Deserialize <MessageBase>(new ReadOnlySpan <byte>(data));

                if (msg.Type == "LoadContract")
                {
                    LoadMessage lmsg = JsonSerializer.Deserialize <LoadMessage>(new ReadOnlySpan <byte>(data));
                    if (lmsg.Data != "")
                    {
                        contractLoadingThread.addTask(lmsg, port);
                    }
                }
                if (msg.Type == "RecordRequest")
                {
                    GetRecordMessage grmsg = JsonSerializer.Deserialize <GetRecordMessage>(new ReadOnlySpan <byte>(data));
                    ServerLogger.Instance.writeLog($"Server: {grmsg.Type}, route: {grmsg.Route}");
                    List <byte[]> res = RouteContainer.Instance.getDataByRoute(grmsg.Route);
                    send <GetRecordMessage>(port, new GetRecordMessage(grmsg.Route, new byte[0], true));
                    foreach (byte[] item in res)
                    {
                        send <GetRecordMessage>(port, new GetRecordMessage(grmsg.Route, item, false));
                    }
                }
            }
            catch (Exception ex)
            {
                ServerLogger.Instance.writeLog($"Server error: {ex.StackTrace}\n {ex.Message}");
                send <ErrorMessage>(port, new ErrorMessage(ex.Message));
            }
        }
예제 #3
0
 public void LoadAssets(LoadMessage message)
 {
     lock (_assetLoaderQueue)
     {
         Console.WriteLine("Putting load message onto the queue...");
         _loading.DoneLoading = false;
         _assetLoaderQueue.Enqueue(message);
     }
 }
예제 #4
0
        public async Task <MediaStatus> LoadAsync(
            ISender sender,
            string sessionId,
            MediaInformation media,
            bool autoPlay = true,
            params int[] activeTrackIds)
        {
            var msg = new LoadMessage()
            {
                Media          = media,
                AutoPlay       = autoPlay,
                ActiveTrackIds = activeTrackIds.ToList(),
                SessionId      = sessionId
            };

            return(await SendAsync(sender, msg));
        }
        private void handleData(byte[] data, ClientView view)
        {
            try
            {
                MessageBase msg = JsonSerializer.Deserialize <MessageBase>(new ReadOnlySpan <byte>(data));

                if (msg.Type == "ErrorMessage")
                {
                    ErrorMessage ermsg = JsonSerializer.Deserialize <ErrorMessage>(new ReadOnlySpan <byte>(data));
                    view.handleMessage(ermsg, msg.Type);
                }
                if (msg.Type == "LoadContract")
                {
                    LoadMessage lmsg = JsonSerializer.Deserialize <LoadMessage>(new ReadOnlySpan <byte>(data));
                    view.handleMessage(lmsg, msg.Type);
                }
                if (msg.Type == "ProgressInfo")
                {
                    ProgressInfoMessage pimsg = JsonSerializer.Deserialize <ProgressInfoMessage>(new ReadOnlySpan <byte>(data));
                    view.handleMessage(pimsg, msg.Type);
                }
                if (msg.Type == "RecordRequest")
                {
                    GetRecordMessage grmsg = JsonSerializer.Deserialize <GetRecordMessage>(new ReadOnlySpan <byte>(data));
                    view.handleMessage(grmsg, msg.Type);
                }
                if (msg.Type == "DataChanged")
                {
                    DatabaseChangedMessage dbcmsg = JsonSerializer.Deserialize <DatabaseChangedMessage>(new ReadOnlySpan <byte>(data));
                    view.handleMessage(dbcmsg, msg.Type);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                ErrorMessage ermsg = new ErrorMessage(ex.StackTrace);
                view.handleMessage(ermsg, "ErrorMessage");
            }
        }
예제 #6
0
        private void Load(LoadMessage msg)
        {
            // Create an instance of the open file dialog box.
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            // Set filter options and filter index.
            openFileDialog1.Filter      = "Xml files (*.xml)|*.xml|Text files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;

            openFileDialog1.Multiselect = true;

            // Call the ShowDialog method to show the dialog box.
            bool?userClickedOK = openFileDialog1.ShowDialog();

            try
            {
                // Process input if the user clicked OK.
                if (userClickedOK == true)
                {
                    // Open the selected file to read.
                    System.IO.Stream fileStream = openFileDialog1.OpenFile();

                    XmlSerializer xs = new XmlSerializer(typeof(GameData));
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
                    {
                        ApplicationModel.GameModel.ImportData((GameData)xs.Deserialize(reader));
                        ApplicationViewModel.GameViewModel.ApplyModel(ApplicationModel.GameModel);
                    }
                    fileStream.Close();
                }
            }
            catch (Exception e)
            {
            }
            Dispatcher.Invoke(new Action(() => { }), DispatcherPriority.ContextIdle, null);
        }
 public void startListening()
 {
     while (true)
     {
         waitForTask.WaitOne();
         while (tasks.Count > 0)
         {
             ProgressInfoMessage progress = new ProgressInfoMessage($"Analyzing {tasks[0].Contract.FileName}.");
             TcpServerWrapper.Instance.send <ProgressInfoMessage>(tasks[0].Port, progress);
             ServerLogger.Instance.writeLog(progress.Info);
             tasks[0].executeTask();
             LoadMessage resp = new LoadMessage("", tasks[0].Contract.FileName);
             TcpServerWrapper.Instance.send <LoadMessage>(tasks[0].Port, resp);
             TcpServerWrapper.Instance.sendToAll <DatabaseChangedMessage>(new DatabaseChangedMessage());
             ServerLogger.Instance.writeLog($"{resp.FileName} analyzed succesfully.");
             tasks.RemoveAt(0);
         }
         waitForTask.Reset();
         if (endThread)
         {
             break;
         }
     }
 }
예제 #8
0
 public LoadingTask(LoadMessage contract, string port)
 {
     Contract = contract;
     Port     = port;
 }
 public void addTask(LoadMessage contract, string port)
 {
     tasks.Add(new LoadingTask(contract, port));
     waitForTask.Set();
 }
예제 #10
0
        public void ConsumeLoadMessage(LoadMessage message)
        {
            if (message is SaveLoadMessage)
            {
            }
            else
            {
                var newContentManagers         = new Dictionary <RegionNames, ContentManager>();
                var newCharacterContentManager = new ContentManager(_serviceProvider, _rootDirectory);
                var newCharacterTextures       = new Dictionary <int, Texture2D>();
                var newRegionTextures          = new Dictionary <RegionNames, Dictionary <int, Texture2D> >();
                var newGameObjects             = new Dictionary <RegionNames, List <GameObject> >();
                var newCameraObjects           = new Dictionary <RegionNames, List <GameObject> >();
                var newBgObjects = new Dictionary <RegionNames, List <GameObject> >();
                var newFgObjects = new Dictionary <RegionNames, List <GameObject> >();
                foreach (RegionNames r in ((RegionLoadMessage)message).RegionsToLoad)
                {
                    LoadRegion(r, newContentManagers, newRegionTextures, newGameObjects, newCameraObjects, newBgObjects, newFgObjects);
                }

                if (((RegionLoadMessage)message).SwapOutCharacterHandler)
                {
                    LoadCharacters(((RegionLoadMessage)message).CharacterThemeToLoad, newCharacterContentManager, newCharacterTextures);
                }

                lock (_loading.Sync)
                {
                    foreach (RegionNames r in ((RegionLoadMessage)message).RegionsToUnload)
                    {
                        _regionContentManagers[r].Unload();
                        _regionContentManagers.Remove(r);
                        _regionTextures.Remove(r);
                        _regionGameObjects.Remove(r);
                        _cameraCollisionObjects.Remove(r);
                        _bgGameObjects.Remove(r);
                        _fgGameObjects.Remove(r);

                        if (((RegionLoadMessage)message).SwapOutCharacterHandler)
                        {
                            _characterContentManager.Unload();
                        }
                    }

                    foreach (RegionNames r in newContentManagers.Keys)
                    {
                        _regionContentManagers.Add(r, newContentManagers[r]);
                        _regionTextures.Add(r, newRegionTextures[r]);
                        _regionGameObjects.Add(r, newGameObjects[r]);
                        _cameraCollisionObjects.Add(r, newCameraObjects[r]);
                        _bgGameObjects.Add(r, newBgObjects[r]);
                        _fgGameObjects.Add(r, newFgObjects[r]);

                        if (((RegionLoadMessage)message).SwapOutCharacterHandler)
                        {
                            _characterContentManager = newCharacterContentManager;
                            _characterTextures       = newCharacterTextures;
                        }
                    }
                }
            }
            _loading.DoneLoading = true;
        }