public CodeArtifactCollection GenerateArtifacts(SigSpecDocument document) { var resolver = new TypeScriptTypeResolver(_settings.TypeScriptGeneratorSettings); resolver.RegisterSchemaDefinitions(document.Definitions); var artifacts = new List <CodeArtifact>(); foreach (var hub in document.Hubs) { var hubModel = new HubModel(hub.Key, hub.Value, resolver); var template = _settings.TypeScriptGeneratorSettings.TemplateFactory.CreateTemplate("TypeScript", "Hub", hubModel); artifacts.Add(new CodeArtifact(hubModel.Name, CodeArtifactType.Class, CodeArtifactLanguage.TypeScript, template)); } if (_settings.GenerateDtoTypes) { var generator = new TypeScriptGenerator(document, _settings.TypeScriptGeneratorSettings, resolver); var types = generator.GenerateTypes(); return(new CodeArtifactCollection(artifacts.Concat(types.Artifacts), types.ExtensionCode)); } else { var extensionCode = new TypeScriptExtensionCode(_settings.TypeScriptGeneratorSettings.ExtensionCode, _settings.TypeScriptGeneratorSettings.ExtendedClasses); return(new CodeArtifactCollection(artifacts, extensionCode)); } }
public void StartGame(CS_StartGame cs, string connectionId) { try { SC_StartGame sc = new SC_StartGame() { Code = 1 }; var host = _host.Find(r => r.GameName == cs.GameName && r.ConnectionId == connectionId); if (host == null) { sc.Code = 105; sc.Msg = "StartGame Fail"; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(sc)); } host.State = RoomState.Play; HubConnector.Client(connectionId).StartGame(JsonConvert.SerializeObject(sc)); } catch (Exception ex) { HubModel error = new HubModel() { Code = 105, Msg = "StartGame Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
public ActionResult Index(bool ajax = false) { SetMainTab(MainTab.Dashboard); var items = new List <IMonitorStatus>(); var nodes = DashboardData.AllNodes .Where(s => !s.IsUnwatched) .Where(s => s.CPULoad >= 0 || s.MemoryUsed >= 0) .OrderByWorst(s => s.CPUMonitorStatus()) .ThenByWorst(s => s.MemoryMonitorStatus()) .ThenBy(s => s.Category.Index) .ThenBy(s => s.PrettyName); // Dashboard items.AddRange(nodes); items.AddRange(SQLCluster.AllClusters.SelectMany(c => c.AvailabilityGroups)); // TODO: Redis items.AddRange(ElasticCluster.AllClusters.OrderByWorst().ThenBy(c => c.Name)); // TODO: Exceptions items.AddRange(HAProxyGroup.AllGroups.OrderByWorst().ThenBy(g => g.Name)); var vd = new HubModel { Items = items }; return(View(vd)); }
public void ExitRoom(CS_ExitRoom cs, string connectionId) { try { var host = _host.Find(r => r.PrivateIp == cs.PrivateIp && r.Port == cs.Port && r.GameName == cs.GameName); if (host == null) { HubModel sc = new HubModel() { Code = 104, Msg = "ExitRoom Fail", }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(sc)); } host.Player--; } catch (Exception ex) { HubModel error = new HubModel() { Code = 103, Msg = "EnterRoom Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
public void GetRoomList(CS_RoomList cs, string connectionId) { try { SC_RoomList sc = new SC_RoomList() { Code = 1, RoomList = new List <SC_Room>(), }; for (int i = 0; i < _host.Count; i++) { if (_host[i].State == RoomState.Wait && _host[i].GameName == cs.GameName) { sc.RoomList.Add(new SC_Room() { PrivateIp = _host[i].PrivateIp, Port = _host[i].Port, Player = _host[i].Player, }); } } HubConnector.Client(connectionId).GetRoomList(JsonConvert.SerializeObject(sc)); } catch (Exception ex) { HubModel error = new HubModel() { Code = 102, Msg = "GetRoomList Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
private void Show3() { ThreadPool.QueueUserWorkItem(e => { while (true) { if (Factory.ContainerList[2].dic.Count == 0) { Clients.All.clear3(); Thread.Sleep(200); } else { List <HubModel> lc = new List <HubModel>(); var icc = Factory.ContainerList[2].dic.ToArray(); for (int i = 0; i < icc.Length; i++) { HubModel m = new HubModel() { UserId = icc[i].Key, Count = icc[i].Value.Count() }; lc.Add(m); } Clients.All.update3(lc); } } }); }
public IEnumerable <CodeArtifact> GenerateArtifacts(SigSpecDocument document) { var resolver = new TypeScriptTypeResolver(this._settings.TypeScriptGeneratorSettings); resolver.RegisterSchemaDefinitions(document.Definitions); var artifacts = new List <CodeArtifact>(); foreach (var hub in document.Hubs) { var hubModel = new HubModel(hub.Key, hub.Value, resolver); var template = this._settings.TypeScriptGeneratorSettings.TemplateFactory.CreateTemplate("TypeScript", "Hub", hubModel); artifacts.Add(new CodeArtifact(hubModel.Name, CodeArtifactType.Class, CodeArtifactLanguage.TypeScript, CodeArtifactCategory.Client, template)); } if (this._settings.GenerateDtoTypes) { var generator = new TypeScriptGenerator(document, this._settings.TypeScriptGeneratorSettings, resolver); var types = generator.GenerateTypes(); return(artifacts.Concat(types)); } else { return(artifacts); } }
public async Task CreateNewPage(Guid guid) { Context.Items.Clear(); Context.Items.Add("guid", guid); HubModel model = new HubModel(guid); if (!Models.TryAdd(guid, model)) { Models[guid].Reset(); } await Groups.AddToGroupAsync(Context.ConnectionId, guid.ToString()); await Clients.Group(guid.ToString()).SendAsync("VisitorJoined", 1); }
public IActionResult AddHub(HubModel model) { try { _hubService.CreateHub(model.Title, model.Description, User.Identity.Name); _toastNotification.AddSuccessToastMessage("Hub has successfully created."); } catch (Exception e) { _toastNotification.AddErrorToastMessage("Hub with such a name already exists."); } return(RedirectToAction("Index")); }
public void CreateRoom(CS_CreateRoom cs, string connectionId) { try { SC_CreateRoom sc = new SC_CreateRoom() { Code = 1, }; Room room = _host.Find(r => r.PrivateIp == cs.PrivateIp && r.Port == cs.Port); if (room != null) { sc.Code = 101; sc.Msg = "CreateRoom Fail. Ip & Port are already using"; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(sc)); } Room data = new Room() { ConnectionId = connectionId, PrivateIp = cs.PrivateIp, Port = cs.Port, State = RoomState.Wait, GameName = cs.GameName, Player = 1, }; _host.Add(data); User user = new User() { ConnectionId = connectionId, RoonNum = _host.Count - 1, }; _user.Add(user); HubConnector.Client(connectionId).ResponseCreateRoom(JsonConvert.SerializeObject(sc)); } catch (Exception ex) { HubModel error = new HubModel() { Code = 101, Msg = "CreateRoom Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
public ActionResult Index(string message = null) { //!!Add Signal-R updates for everyone HubModel model = new HubModel(); model.BoardList = HubQueries.GetAllPublicBoards(); model.Message = message; foreach (BoardModel board in model.BoardList) { if (board.Password != null) { board.IsPasswordProtected = true; } } return(View(model)); }
public void OnDisconnected(string connectionId) { try { Room host = _host.Find(r => r.ConnectionId == connectionId); if (host != null) { _host.Remove(host); } } catch (Exception ex) { HubModel error = new HubModel() { Code = 2, Msg = "Disconnect Exception Fail : " + ex.ToString(), }; HubConnector.Client(connectionId).ErrorMsg(JsonConvert.SerializeObject(error)); } }
public ActionResult ShowHubListing() { var hub = _strongContentService.GetCurrentNode <IHub>(); if (hub == null || hub.HideListing) { // This is not a hub, so can't have a listing. return(null); } var pages = _strongContentService.GetChildNodes <IListablePage>(hub).Where(p => !p.HideFromParentListing); var map = AutoMapper.Mapper.CreateMap <IListablePage, ListingItem>(); var pageModels = pages.Select(AutoMapper.Mapper.Map <ListingItem>); var model = new HubModel { Pages = pageModels }; return(View("~/Views/Partials/HubListingView.cshtml", model)); }
public ActionResult Index() { var vd = new HubModel(); return(View(vd)); }