void OnServerGotClient(NetworkMessage netMsg) { dWin.Text("Server Connected to client " + netMsg.conn.connectionId); // send everyone else to the new player. foreach (KeyValuePair <int, Player> entry in players) { var playerMessage = new PlayerMessage(); playerMessage.id = entry.Value.id; playerMessage.name = entry.Value.name; playerMessage.ready = entry.Value.ready; playerMessage.classType = (int)entry.Value.classType; netMsg.conn.Send(NetworkMessages.Player, playerMessage); } players[netMsg.conn.connectionId] = new Player(); players[netMsg.conn.connectionId].id = netMsg.conn.connectionId; // send the new player to everyone else. var idMessage = new IdMessage(); idMessage.id = netMsg.conn.connectionId; NetworkServer.SendToAll(NetworkMessages.Id, idMessage); dWin.Text(GetPlayerStats()); }
public override Task <BoolMessage> DeletePost(IdMessage idMessage, ServerCallContext context) { return(Task.FromResult(new BoolMessage { Value = new Post().DeletePost(idMessage.Id) != 0 })); }
private void CacheIdEvents(IdMessage msg) { Task.Run(() => { if (AuthenticatedUser == null) { return; } switch (msg.Type) { case MessageType.DeleteStatus: if (msg.UserId == AuthenticatedUser.Id) { AuthenticatedUser.StatusesCount--; RaisePropertyChanged(() => AuthenticatedUser); if (IsMyRetweetInCache(msg.UpToStatusId ?? 0)) { RemoveRetweetCache(msg.UpToStatusId ?? 0); CacheContext.SubmitChanges(); } } break; } }); }
private async void NotifyIdEventUpdate(IdMessage msg) { CacheIdEvents(msg); await ProcessIdEvents(msg); RaisePropertyChanged("IdEvent"); await Task.Run(() => { foreach (var p in Plugins) { p.IdEventUpdate(msg.DeepCopy(), PluginMonitoringToken); } }); }
public void CreateGame3() { Player P = new Player("Anna"); GameController GameCo = new GameController(); Object Obj = GameCo.NewGame(P); IdMessage Idm1 = (IdMessage)(((OkObjectResult)Obj).Value); P = new Player("Anna"); Obj = GameCo.Joingame(Idm1.Id, P); Console.WriteLine(Obj.GetType().Name); Assert.IsTrue(Obj.GetType().Name.CompareTo("BadRequestObjectResult") == 0); }
private Task <IdMessage> ProcessIdEvents(IdMessage msg) { return(Task.Run(() => { var ret = msg.DeepCopy(); if (ret == null) { return msg; } foreach (var i in Plugins) { ret = i.IdEventUpdateDestructive(ret, PluginMonitoringToken) ?? ret; } return ret; })); }
public async Task DeleteWorker(IdMessage idMessage) { if (client == null || token == "") { Debug.WriteLine("Null client or token"); return; } try { await client.DeleteWorkerByIDAsync(idMessage, headers); } catch (Exception e) { Debug.WriteLine(e.Message); } }
public void CreateGame7() { GameController GameCo = new GameController(); Player P1 = new Player("Anna"); Player P2 = new Player("Emelie"); Object Obj = GameCo.NewGame(P1); IdMessage Idm1 = ((IdMessage)((OkObjectResult)Obj).Value); GameCo.Joingame(Idm1.Id, P2); P1.GameMove = "scissors"; GameCo.Move(Idm1.Id, P1); P2.GameMove = "rock"; GameCo.Move(Idm1.Id, P2); RPSGameDTO gameDTO = (RPSGameDTO)GameCo.GetStatus(Idm1.Id); Console.WriteLine(gameDTO.Winner); Assert.IsTrue(gameDTO.Winner == P2.PlayerName); }
public void CreateGame2() { Player P = new Player("Anna"); GameController GameCo = new GameController(); Object Obj = GameCo.NewGame(P); Assert.IsTrue(Obj.GetType().Name.CompareTo("OkObjectResult") == 0); IdMessage Idm1 = ((IdMessage)((OkObjectResult)Obj).Value); P = new Player("Emelie"); Obj = GameCo.Joingame(Idm1.Id, P); Assert.IsTrue(Obj.GetType().Name.CompareTo("RPSGameDTO") == 0); RPSGameDTO gameDTO = (RPSGameDTO)Obj; // Check that a rew game has been started Assert.AreEqual(gameDTO.Id, Idm1.Id); }
public void CreateGame5() { Player P = new Player("Anna"); GameController GameCo = new GameController(); Object Obj = GameCo.NewGame(P); IdMessage Idm1 = ((IdMessage)((OkObjectResult)Obj).Value); GameCo.Joingame(Idm1.Id, new Player("Emelie")); bool testok = false; try { P.GameMove = "paperr"; GameCo.Move(Idm1.Id, P); } catch (Exception) { testok = true; } Assert.IsTrue(testok); }
internal void RaiseIdEvent(IdMessage msg) { if (IdReceived == null) { return; } var s = IdReceived.GetInvocationList().Select(p => p as Action <IdMessage>); foreach (var i in s.Where(p => p != null)) { try { i(msg); } catch (Exception e) { Instance.LogError("IDイベント受信時イベントでエラーが発生しました\n" + e.Message); Instance.SaveLog(); } } }
public void CreateGame1() { Player P = new Player("Anna"); GameController GameCo = new GameController(); Object Obj = GameCo.NewGame(P); Console.WriteLine(Obj.GetType().Name); // Check the return type Assert.IsTrue(Obj.GetType().Name.CompareTo("OkObjectResult") == 0); IdMessage Idm1 = (IdMessage)(((OkObjectResult)Obj).Value); // Create a new game P = new Player("Emelie"); Obj = GameCo.NewGame(P); IdMessage Idm2 = ((IdMessage)((OkObjectResult)Obj).Value); // Check that a rew game has been started Assert.AreNotEqual(Idm1.Id, Idm2.Id); Assert.IsTrue(GameController.gGameList.Count == 2); }
void GotClient(NetworkMessage netMsg) { Debug.Log("Got client..."); // send everyone else to the new player. foreach (KeyValuePair <int, BasePlayer> entry in players) { var playerMessage = new PlayerMessage(); playerMessage.id = entry.Value.GetPlayerId(); playerMessage.name = entry.Value.GetName(); playerMessage.ready = entry.Value.ready; playerMessage.role = entry.Value.GetRoleId(); netMsg.conn.Send(CustomNetMsg.Player, playerMessage); } //default anme is player + id, default roleint is 0 players[netMsg.conn.connectionId] = new BasePlayer("Player " + netMsg.conn.connectionId, 0, netMsg.conn.connectionId); //players[netMsg.conn.connectionId].id = netMsg.conn.connectionId; if (lobbyGui != null) { lobbyGui.UpdateUI(players); } // send the new player to everyone else. var idMessage = new IdMessage(); idMessage.id = netMsg.conn.connectionId; NetworkServer.SendToAll(CustomNetMsg.Id, idMessage); // send server dissonance id to the new player. var dissonanceIdMessage = new DissonanceIdMessage(); dissonanceIdMessage.id = 0; dissonanceIdMessage.dissonanceId = UNetDissonance.PlayerName; netMsg.conn.Send(CustomNetMsg.DissonanceId, dissonanceIdMessage); }
internal IdMessage RaiseIdEventDestructive(IdMessage msg) { var m = msg; if (IdReceivedDestructive == null) { return(null); } var s = IdReceivedDestructive.GetInvocationList().Select(p => p as Func <IdMessage, IdMessage>); foreach (var i in s.Where(p => p != null)) { try { m = i(m); } catch (Exception e) { Instance.LogError("IDイベント受信時破壊的イベントでエラーが発生しました\n" + e.Message); Instance.SaveLog(); } } return(m); }
public IActionResult Index(IdMessage message) { MessageVM model = new MessageVM(); if (message == IdMessage.AccountLock) { model.Topic = "Blokada"; model.Message = "Twoje konto zostało zablokowane spróbuj ponownie później."; model.LinkUrl = "/Account/LogIn"; model.LinkName = "Wróć"; } else if (message == IdMessage.SendConfirmEmailSucces) { model.Topic = "Powodzenie"; model.Message = "Na Adres Email został wysłany link potwierdzajacy konto."; model.LinkUrl = "/Account/LogIn"; model.LinkName = "Wróć"; } else if (message == IdMessage.SendConfirmEmailError) { model.Topic = "Błąd"; model.Message = "Niestety nie udało się wysłać maila z potwierdzeniem, skontaktuj się proszę z administratorem."; model.LinkUrl = "/Account/LogIn"; model.LinkName = "Wróć"; } else if (message == IdMessage.EmailConfirmedSucces) { model.Topic = "Powodzenie"; model.Message = "Dziękujemy za potwierdzenie konta, zostaniesz przekierowany do ekranu logowania."; model.LinkUrl = "/Account/LogIn"; model.LinkName = "Wróć"; } else if (message == IdMessage.EmailConfirmedError) { model.Topic = "Błąd"; model.Message = "Niestety nie udało się potwierdzic konta, skontaktuj się proszę z administartorem."; model.LinkUrl = "/Account/LogIn"; model.LinkName = "Wróć"; } else if (message == IdMessage.ResetPasswordTokenSendSucces) { model.Topic = "Powodzenie"; model.Message = "Link do zmiany hasła został wysłany na podany adres Email."; model.LinkUrl = "/Account/LogIn"; model.LinkName = "Wróć"; } else if (message == IdMessage.ResetPasswordTokenSendError) { model.Topic = "Błąd"; model.Message = "Niestety nie udało sie wysłać liku do zmiany hasła."; model.LinkUrl = "/Account/LogIn"; model.LinkName = "Wróć"; } else if (message == IdMessage.ResetPasswordSucces) { model.Topic = "Powodzenie"; model.Message = "Hasło zostało pomyślnie zresetowane."; model.LinkUrl = "/Account/LogIn"; model.LinkName = "Wróć"; } else if (message == IdMessage.ChangePasswordSucces) { model.Topic = "Powodzenie"; model.Message = "Hasło zostało pomyślnie zmienione."; model.LinkUrl = "/User/Index"; model.LinkName = "Wróć"; } else if (message == IdMessage.AddPhoneNumberSucces) { model.Topic = "Powodzenie"; model.Message = "Numer wymaga potwierdzenie dlatego został wysłany sms z kodem potwierdzającym."; model.LinkUrl = "/User/ConfirmPhoneNumber"; model.LinkName = "Potwierdź"; } else if (message == IdMessage.AddPhoneNumberError) { model.Topic = "Błąd"; model.Message = "Niestety nie udało się dodać numeru telefonu."; model.LinkUrl = "/User/Index"; model.LinkName = "Wróć"; } else if (message == IdMessage.RemovePhoneNumberSucces) { model.Topic = "Powodzenie"; model.Message = "Numer telefonu został usunięty pomyślnie."; model.LinkUrl = "/User/Index"; model.LinkName = "Wróć"; } else if (message == IdMessage.RemovePhoneNumberError) { model.Topic = "Błąd"; model.Message = "Nie udało się usunąć numeru telefonu."; model.LinkUrl = "/User/Index"; model.LinkName = "Wróć"; } else if (message == IdMessage.ConfirmedPhoneNumberSucces) { model.Topic = "Powodzenie"; model.Message = "Numer telefonu został potwierdzony pomyślnie."; model.LinkUrl = "/User/Index"; model.LinkName = "OK"; } else if (message == IdMessage.ConfirmedPhoneNumberError) { model.Topic = "Błąd"; model.Message = "Niestety nie udało się potwierdzić numeru telefonu."; model.LinkUrl = "/User/Index"; model.LinkName = "Wróć"; } else if (message == IdMessage.AdminSendConfirmationEmailSucces) { model.Topic = "Powodzenie"; model.Message = "Na adres klienta został wysłany link do potwierdzenia adresu Email."; model.LinkUrl = "/ManagementAdmin/Index"; model.LinkName = "OK"; } else if (message == IdMessage.AdminSendConfirmationEmailError) { model.Topic = "Błąd"; model.Message = "Niestety nie udało się wysłać potwierdzenia na adres Email."; model.LinkUrl = "/ManagementAdmin/Index"; model.LinkName = "Wróć"; } else if (message == IdMessage.AdminDeleteAccountSucces) { model.Topic = "Powodzenie"; model.Message = "Użytkownik został prawidłowo usunięty."; model.LinkUrl = "/ManagementAdmin/Index"; model.LinkName = "OK"; } else if (message == IdMessage.AdminDeleteAccountError) { model.Topic = "Błąd"; model.Message = "Niestety nie udało się usunąć użytkownika w logach zostały zawarte szczegóły."; model.LinkUrl = "/ManagementAdmin/Index"; model.LinkName = "Wróć"; } else if (message == IdMessage.UserDeleteAccountSucces) { model.Topic = "Powodzenie"; model.Message = "Konto zostało pomyślnie usunięte, dziękujemy za uzytkowanie naszego oprogramowania."; model.LinkUrl = "/Account/LogIn"; model.LinkName = "OK"; } else { return(RedirectToAction("Index", "Home")); } return(View(model)); }
/// <summary> /// 受信したIDのイベントについて、スクリプトの処理をします。 /// このイベントは、ツイートの表示前に処理されます。 /// </summary> /// <param name="msg">IdMessage</param> /// <param name="mon">非同期的に処理するためのモニター用オブジェクト</param> public abstract IdMessage IdEventUpdateDestructive(IdMessage msg, object mon);
public override Task <CommentMessage> GetCommentById(IdMessage idMessage, ServerCallContext context) { return(Task.FromResult(EntityCommentToMessageComment(new Comment().GetCommentById(idMessage.Id)))); }
public override Task <PostMessage> GetPostById(IdMessage idMessage, ServerCallContext context) { return(Task.FromResult(EntityPostToMessagePost(new Post().GetPostById(idMessage.Id)))); }
/// <summary> /// 受信したIDのイベントについて、スクリプトの処理をします。 /// </summary> /// <param name="msg">IdMessage</param> /// <param name="mon">非同期的に処理するためのモニター用オブジェクト</param> public abstract void IdEventUpdate(IdMessage msg, object mon);
public override Task <PrisonerMessage> GetPrisonerByID(IdMessage request, ServerCallContext context) { Prisoner p = unitOfWork.PrisonerRepo.GetByID(request.Id); return(Task.FromResult(ConversionStuff.PrisonerToMessage(p))); }
public override Task <WorkerMessage> GetWorkerByID(IdMessage request, ServerCallContext context) { return(Task.FromResult(ConversionStuff.WorkerToMessage(unitOfWork.WorkerRepo.GetByID(request.Id)))); }
internal void RaiseIdEvent(IdMessage msg) { if (IdReceived == null) return; var s = IdReceived.GetInvocationList().Select(p => p as Action<IdMessage>); foreach (var i in s.Where(p => p != null)) { try { i(msg); } catch (Exception e) { Instance.LogError("IDイベント受信時イベントでエラーが発生しました\n" + e.Message); Instance.SaveLog(); } } }
private Task<IdMessage> ProcessIdEvents(IdMessage msg) { return Task.Run(() => { var ret = msg.DeepCopy(); if (ret == null) return msg; foreach (var i in Plugins) ret = i.IdEventUpdateDestructive(ret, PluginMonitoringToken) ?? ret; return ret; }); }
public override Task <LocationMessage> GetLocationByID(IdMessage request, ServerCallContext context) { return(Task.FromResult(ConversionStuff.LocationToMessage(unitOfWork.LocationRepo.GetByID(request.Id)))); }
private void CacheIdEvents(IdMessage msg) { Task.Run(() => { if (AuthenticatedUser == null) return; switch (msg.Type) { case MessageType.DeleteStatus: if (msg.UserId == AuthenticatedUser.Id) { AuthenticatedUser.StatusesCount--; RaisePropertyChanged(() => AuthenticatedUser); if (IsMyRetweetInCache(msg.UpToStatusId ?? 0)) { RemoveRetweetCache(msg.UpToStatusId ?? 0); CacheContext.SubmitChanges(); } } break; } }); }
public override IdMessage IdEventUpdateDestructive(IdMessage msg, object mon) { return ep.RaiseIdEventDestructive(msg); }
public override void IdEventUpdate(IdMessage msg, object mon) { ep.RaiseIdEvent(msg); }
public override Task <JobMessage> GetJobByID(IdMessage request, ServerCallContext context) { return(Task.FromResult(ConversionStuff.JobToMessage(unitOfWork.JobRepo.GetByID(request.Id)))); }
internal IdMessage RaiseIdEventDestructive(IdMessage msg) { var m = msg; if (IdReceivedDestructive == null) return null; var s = IdReceivedDestructive.GetInvocationList().Select(p => p as Func<IdMessage, IdMessage>); foreach (var i in s.Where(p => p != null)) { try { m = i(m); } catch (Exception e) { Instance.LogError("IDイベント受信時破壊的イベントでエラーが発生しました\n" + e.Message); Instance.SaveLog(); } } return m; }
public override Task <Empty> DeleteJobByID(IdMessage request, ServerCallContext context) { unitOfWork.JobRepo.Delete(request.Id); unitOfWork.Save(); return(Task.FromResult(new Empty())); }
private async void NotifyIdEventUpdate(IdMessage msg) { CacheIdEvents(msg); await ProcessIdEvents(msg); RaisePropertyChanged("IdEvent"); await Task.Run(() => { foreach (var p in Plugins) p.IdEventUpdate(msg.DeepCopy(), PluginMonitoringToken); }); }
public override IdMessage IdEventUpdateDestructive(IdMessage msg, object mon) { return(ep.RaiseIdEventDestructive(msg)); }