public override void processMessage (RawMessage message) { MutantEightLeggedMinion parentMinion = (MutantEightLeggedMinion) Engine.Game.getMinionById( message.getInt("iid")); int spawningCount = message.getInt("c"); if (spawningCount == 0) return; int[] spawningIds = message.getIntArray("sid"); int[] deadIds = message.getIntArray("did"); List<MutantEightLeggedSpawningMinion> spawnings = new List<MutantEightLeggedSpawningMinion>(); MutantEightLeggedSpawningMinion spawning; Minion deadMinion; for (int i = 0; i < spawningCount; i++) { deadMinion = Engine.Game.getMinionById(deadIds[i]); if (deadMinion != null) { spawning = parentMinion.createSpawning(); spawning.instanceId = spawningIds[i]; spawnings.Add(spawning); deadMinion.position.board.AddMinionSpecificPosition(spawning, deadMinion.position.pathPosition); } } Runner.Graphics.minion_mutantEightLegged_spawn(parentMinion,spawnings); }
public static void sendMessage(Type nodeType) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId( typeof(LUnlockNodeRequest) )); msg.putInt("tid",TypeIdGenerator.getScienceNodeIds (nodeType)); Network.server.SendMessage(msg); }
public static void sendMessage(string scienceType) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId( typeof(LEnterQueueRequest) )); msg.putUTF8String("st",scienceType); Network.server.SendMessage(msg); }
public override void processMessage(RawMessage message) { float seconds = message.getFloat("s"); Engine.Game.pauseTime = seconds; Engine.Game.setState( Engine.Game.GameState.STARTCOUNTDOWN ); Runner.Graphics.displayStartCountDown(seconds); }
public override void processMessage(RawMessage message, User user) { if (user.userState == User.UserState.GAME ) { OutgoingMessages.Game.GChatMessage.sendMessage(user, message.getUTF8String("cmd")); } }
public override void processMessage(RawMessage message, User user) { if (user.player != null && user.player.playerState != Player.PlayerState.DEAD && // adam oyunda mi, ölü mü user.player.game.gameState == Science_Wars_Server.Game.GameState.PLAYTIME && // oyun pause olmamis ya da bitmemis degil mi? user.player.board.nextBoard.boardState != Board.BoardState.COLLAPSING) // onumuzdeki board çöküyor mu? { int typeId = message.getInt("tid"); if (typeId < 0 || typeId >= user.unlockedMinions.Length) return; if (user.player.availableMinions[typeId] == false) // bu availableMinions zaten sadece o scienceType a ait minionlara true iceriyor. Bir daha science type kontrolu yapmaya gerek yok return; Minion minion = (Minion) Activator.CreateInstance(TypeIdGenerator.getMinionType(typeId),user.player.game, user.player); if (user.player.trySpendCash(minion.getCost())) { // STATCODE PlayerStats pStats = user.player.game.statTracker.getPlayerStatsOfPlayer(user.player); pStats.minionsSend += 1; user.player.addIncome(minion.getIncome()); user.player.board.nextBoard.AddMinion(minion); OutgoingMessages.Game.GCreateMinionResult.sendMessage(user.player.game.players, minion); } } }
public static void sendMessage(bool result) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GReadyStateResult))); msg.putBool("r", result); Network.server.SendMessage(msg); }
public override void processMessage (RawMessage message) { int tid = message.getInt("tid"); Minion minion = (Minion) System.Activator.CreateInstance( TypeIdGenerator.getMinionType( tid )); User user = Assets.Scripts.Engine.Game.getUserById(message.getInt("uid")); if (user != null) // random minionlarda null gelebilir. { minion.ownerPlayer = user.player; if (user.player == PlayerMe.self) { PlayerMe.income += minion.getIncome(); PlayerMe.cash -= minion.getCost(); Runner.Graphics.updateCashAndIncome(); } } minion.instanceId = message.getInt("iid"); minion.position = new MinionPosition(); minion.position.pathPosition = new PathPosition(0,0); minion.position.board = Assets.Scripts.Engine.Game.getBoardById( message.getInt ("bid")); minion.position.pathPosition.pointIndex = message.getInt("cid"); minion.position.pathPosition.ratio = message.getFloat("t"); minion.position.board.AddMinion(minion); Runner.Graphics.createMinion(minion); }
public static void sendMessage(ICollection<Player> recievers) { RawMessage bigMsg = new RawMessage(); bigMsg.putInt("id", TypeIdGenerator.getMessageId(typeof(GLoadingStateRequest))); List<RawMessage> userMsgs = new List<RawMessage>(); foreach (Player player in recievers) { RawMessage msg = new RawMessage(); msg.putInt("btid", TypeIdGenerator.getBoardId(player.board.GetType())); msg.putInt("biid", player.board.instanceId); msg.putUTF8String("st", player.user.selectedScienceTypeInQueue.ToString()); msg.putInt("hps", player.healthPoints); msg.putInt("cash", player.cash); msg.putInt("inc", player.income); msg.putUTF8String("un", player.user.username); msg.putInt("uid", player.user.id); userMsgs.Add(msg); } bigMsg.putRawMessageArray("users", userMsgs.ToArray()); foreach (Player p in recievers) { p.user.session.client.SendMessage(bigMsg); } }
static public void sendMessage( int minionTypeId) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GCreateMinionRequest))); msg.putInt("tid", minionTypeId); Network.server.SendMessage(msg); }
public override void processMessage(RawMessage message, User user) { if (user.userState == User.UserState.LOBBY || user.userState == User.UserState.QUEUE) { OutgoingMessages.Lobby.LChatMessage.sendMessage(user.username, message.getUTF8String("cmd")); } }
public void btn_LoginClick() { RawMessage message = new RawMessage(); message.putUTF8String("username", input_username.text); message.putUTF8String("password", input_password.text); Assets.Scripts.Engine.Network.sslStream.WriteSingleMessage(message); RawMessage msg = Assets.Scripts.Engine.Network.sslStream.ReadSingleMessage(); if (msg == null) { Assets.Scripts.Engine.Network.server.Disconnect(); output_loginResult.text = "Connection is Lost."; return; } if (msg.getBool("response")) { //Assets.Scripts.Engine.Network.sslStream.Close(); // DUE TO A BUG -kardeslerim- WE CANNOT CLOSE THE STREAM. // Cunku close yaparsak, nereden geldigi belirsiz 37 byte, serverda bu client'a ait messageListenera dusuyor. // sadece unity'de oluyor, .net'te duzgun calisiyor. Muhtemelen Mono kaynakli bir sorun. Assets.Scripts.Engine.Network.server.ListenForMessages(); output_loginResult.color = Color.green; } output_loginResult.text = msg.getUTF8String("reason"); input_username.text = ""; input_password.text = ""; input_username.selected = true; StartCoroutine(hideLoginResult()); }
public override void processMessage(RawMessage message, User user) { if (user.player != null && user.player.game != null) { user.player.game.removePlayer( user.player ); } }
public override void processMessage(RawMessage message, User user) { if (user.player != null && user.player.playerState != Player.PlayerState.DEAD && // adam oyunda mi, ölü mü user.player.game.gameState == Science_Wars_Server.Game.GameState.PLAYTIME && // oyun pause olmamis ya da bitmemis degil mi? user.player.board.nextBoard.boardState != Board.BoardState.COLLAPSING) // onumuzdeki board çöküyor mu? { int oldMinionTypeId = message.getInt("tid"); int upgradedMinionTypeId = message.getInt("utid"); if ((oldMinionTypeId < 0 || oldMinionTypeId >= user.player.availableMinions.Length) && // verilen typeId'ler mantikli. (upgradedMinionTypeId < 0 || upgradedMinionTypeId >= user.player.availableMinions.Length)) return; if (user.player.availableMinions[oldMinionTypeId] == false || user.unlockedMinions[upgradedMinionTypeId] == false) // bu minionlar unlocked mi? (dikkat: birinin unlock durumuna bakiyoruz digerinin available durumuna ) return; if( checkIfMinionUpgradableTo( oldMinionTypeId, TypeIdGenerator.getMinionType(upgradedMinionTypeId) ) == false ) // bu minion verilen miniona upgrade edilebilir mi return; Minion minion = (Minion) Activator.CreateInstance(TypeIdGenerator.getMinionType(upgradedMinionTypeId),user.player.game, user.player); // bir instance olusturuyoruz. tek sebebi upgradeCost u ogrenmek. damn... if (user.player.trySpendCash(minion.getUpgradeCost())) { user.player.availableMinions[oldMinionTypeId] = false; user.player.availableMinions[upgradedMinionTypeId] = true; OutgoingMessages.Game.GUpgradeMinionResult.sendMessage(user.player, oldMinionTypeId, upgradedMinionTypeId); } } }
public static void sendMessage(string text) { // TODO User state check RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId( typeof(LChatMessage) )); msg.putUTF8String("cmd", text); Network.server.SendMessage(msg); }
public static void sendMessage(User receiver) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId( typeof(EnterLobby)) ); receiver.session.client.SendMessage(msg); }
public static void sendMessage(User user) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(LReturnQueue))); user.userState = User.UserState.LOBBY; Runner.queue.addUser(user); user.session.client.SendMessage(msg); }
public static void sendMessage() { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GQuitGameRequest))); Network.server.SendMessage(msg); Runner.Graphics.destroyGame(); }
public override void processMessage(RawMessage message) { bool r = message.getBool("r"); if(r) UserMe.self.setState(User.UserState.QUEUE); Runner.Graphics.displayQueueResult(r); }
static public void sendMessage(Engine.Towers.Tower tower, int upgradedTowerTypeId) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GUpgradeTowerRequest))); msg.putInt("tid", upgradedTowerTypeId); msg.putInt("iob", tower.indexOnBoard); Network.server.SendMessage(msg); }
public static void sendMessage(User user, bool result) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(LCancelQueueResult))); msg.putBool("r", result); user.session.client.SendMessage(msg); }
static public void sendMessage(int towerTypeId, int indexOnBoard) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GCreateTowerRequest))); msg.putInt("tid", towerTypeId); msg.putInt("iob", indexOnBoard); Network.server.SendMessage(msg); }
public static void sendMessage( ICollection<Player> receiverPlayers, float seconds) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GEnterStartCountdown))); msg.putFloat("s", seconds); foreach (var player in receiverPlayers) player.user.session.client.SendMessage(msg); }
public override void processMessage(RawMessage message) { int countOfPlayers = message.getInt ("c"); int[] playerIDs = new int[countOfPlayers]; int [] minionsKilled = new int[countOfPlayers]; int[] minionsSend = new int[countOfPlayers]; int[] towersBuilt = new int[countOfPlayers]; int[] missilesFired = new int[countOfPlayers]; int[] minionsPassed = new int[countOfPlayers]; float[] moneyEarned = new float[countOfPlayers]; float[] moneySpend = new float[countOfPlayers]; int[] cashs = new int[countOfPlayers]; int[] incomes = new int[countOfPlayers]; playerIDs = message.getIntArray ("pids"); minionsKilled = message.getIntArray ("mk"); minionsSend = message.getIntArray ("ms"); towersBuilt = message.getIntArray ("tb"); missilesFired = message.getIntArray ("mf"); minionsPassed = message.getIntArray ("mp"); moneyEarned = message.getFloatArray ("mme"); moneySpend = message.getFloatArray ("mms"); cashs = message.getIntArray ("cs"); incomes = message.getIntArray ("inc"); Assets.Scripts.Engine.Game.statTracker = new StatTracker (); Assets.Scripts.Engine.Game.statTracker.playerStatsList = new List<PlayerStats>(); for (int i = 0; i < countOfPlayers; i++) { Player currentPlayer = null; foreach (Player player in Assets.Scripts.Engine.Game.players) { if(player.id == playerIDs[i]) { currentPlayer = player; break; } } PlayerStats newStats = new PlayerStats(currentPlayer); newStats.minionsKilled = minionsKilled[i]; newStats.minionsSend = minionsSend[i]; newStats.towersBuilt = towersBuilt[i]; newStats.missilesFired = missilesFired[i]; newStats.minionsPassed = minionsPassed[i]; newStats.moneyEarned = moneyEarned[i]; newStats.moneySpend = moneySpend[i]; newStats.cash = cashs[i]; newStats.income = incomes[i]; Assets.Scripts.Engine.Game.statTracker.playerStatsList.Add(newStats); } Runner.Graphics.displayEndGameStatistics (); }
public override void processMessage(RawMessage message) { ResourceLoader.loadResources(); Engine.Game.players = new LinkedList<Player>(); Engine.Game.statPlayers = new List<Player> (); Engine.Game.clearOldGameData(); foreach (RawMessage msg in message.getRawMessageArray("users")) { int uid = msg.getInt("uid"); Board board = (Board)Activator.CreateInstance(TypeIdGenerator.getBoardType(msg.getInt("btid"))); //TODO exception handle et yukaridaki bi sinifin icinde. Eger hata gelmisse adamin clienti ya bozulmus // ya oynanmis ya da eskimis demektir. ona gore bi hata mesaji bastir. board.scienceType = (ScienceType) Enum.Parse(typeof(ScienceType), msg.getUTF8String("st")); board.instanceId = msg.getInt("biid"); if (uid == UserMe.self.id) { PlayerMe.self = new Player(msg.getInt("hps"), board); PlayerMe.cash = msg.getInt("cash"); PlayerMe.income = msg.getInt("inc"); PlayerMe.self.user = UserMe.self; UserMe.self.player = PlayerMe.self; setAvailableMinionsOfPlayer(); setAvailableTowersOfPlayer(); Engine.Game.players.AddLast(PlayerMe.self); Engine.Game.statPlayers.Add(PlayerMe.self); board.player = PlayerMe.self; } else { User u = new User(msg.getUTF8String("un"), uid, new Player(msg.getInt("hps"), board)); u.player.user = u; board.player = u.player; Engine.Game.players.AddLast(u.player); Engine.Game.statPlayers.Add(u.player); } } float dist = Engine.Game.calculateBoardDistanceToCenter (Engine.Game.players.Count); for (int i=0; i<Engine.Game.players.Count; i++) { Vector3 rotation = new Vector3(0, i * 360.0f / Engine.Game.players.Count, 0); Engine.Game.players.ElementAt(i).board.rotation = rotation; Engine.Game.players.ElementAt(i).board.position = new Vector3(Mathf.Cos(-1*rotation.y * (Mathf.PI / 180.0f)) * dist, 0, Mathf.Sin(-1*rotation.y * (Mathf.PI / 180.0f)) * dist); Engine.Game.players.ElementAt(i).board.nextBoard = Engine.Game.players.ElementAt((i + 1)%Engine.Game.players.Count).board; Engine.Game.players.ElementAt(i).board.prevBoard = Engine.Game.players.ElementAt((i + Engine.Game.players.Count - 1) % Engine.Game.players.Count).board; } Engine.Game.setState(Engine.Game.GameState.LOADING); }
public static void sendMessage(Player player) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GCashAndIncomeInfo))); msg.putInt("c", player.cash); msg.putInt("i", player.income); player.user.session.client.SendMessage(msg); }
public static new void ToString() { RawMessage message = new RawMessage(); message.Prefix = new RawMessagePrefix("[email protected]"); message.Command = "PRIVMSG"; message.Arguments = new string[] { "rec", "message goes here" }; Assert.AreEqual(":[email protected] PRIVMSG rec :message goes here", message.ToString()); }
public static void sendMessage(string senderUsername,string message) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(LChatMessage)) ); msg.putUTF8String("s", senderUsername); msg.putUTF8String("m", message); foreach (User u in Runner.users.Where( p => p.userState == User.UserState.LOBBY || p.userState == User.UserState.QUEUE )) u.session.client.SendMessage(msg); }
public static void sendMessage(User user, string message) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GChatMessage))); msg.putUTF8String("s", user.username); msg.putUTF8String("m", message); foreach (Player p in user.player.game.players) p.user.session.client.SendMessage(msg); }
public static void sendMessage(ICollection<Player> recievers) { RawMessage msg = new RawMessage(); msg.putInt("id", TypeIdGenerator.getMessageId(typeof(GReadyStateRequest))); msg.putFloat("s", Science_Wars_Server.Game.READY_STATE_END_TIME_DEFAULT); foreach (Player p in recievers) p.user.session.client.SendMessage(msg); }
public void OnMessagePublished(RawMessage message) { Console.WriteLine("pubSucessMessage:" + message.Payload); Console.WriteLine(); }
public void HandleApplicationMessage(RawMessage message, IApplicationOutboundStream responder) => HandleApplicationMessageCheck.IncrementAndGet();
private Boolean ValidationFormData() { if (dtDateBCG.SelectedDate != null) { if (Convert.ToDateTime(dtDateBCG.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtOPV0Date.SelectedDate != null) { if (Convert.ToDateTime(dtOPV0Date.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateOPV1.SelectedDate != null) { if (Convert.ToDateTime(dtDateOPV1.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateRV1.SelectedDate != null) { if (Convert.ToDateTime(dtDateRV1.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateDTaP1.SelectedDate != null) { if (Convert.ToDateTime(dtDateDTaP1.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateHepB1.SelectedDate != null) { if (Convert.ToDateTime(dtDateHepB1.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDatePCV1.SelectedDate != null) { if (Convert.ToDateTime(dtDatePCV1.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateDTaP2.SelectedDate != null) { if (Convert.ToDateTime(dtDateDTaP2.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateHepB2.SelectedDate != null) { if (Convert.ToDateTime(dtDateHepB2.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateDTaP3.SelectedDate != null) { if (Convert.ToDateTime(dtDateDTaP3.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateHepB3.SelectedDate != null) { if (Convert.ToDateTime(dtDateHepB3.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDatePCV2.SelectedDate != null) { if (Convert.ToDateTime(dtDatePCV2.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateRV2.SelectedDate != null) { if (Convert.ToDateTime(dtDateRV2.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateMeasles1.SelectedDate != null) { if (Convert.ToDateTime(dtDateMeasles1.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDatePVC3.SelectedDate != null) { if (Convert.ToDateTime(dtDatePVC3.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateMeasles2.SelectedDate != null) { if (Convert.ToDateTime(dtDateMeasles2.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateDTaP4.SelectedDate != null) { if (Convert.ToDateTime(dtDateDTaP4.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateTd6Yrs.SelectedDate != null) { if (Convert.ToDateTime(dtDateTd6Yrs.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } if (dtDateTd23Yrs.SelectedDate != null) { if (Convert.ToDateTime(dtDateTd23Yrs.SelectedDate.Value) > Convert.ToDateTime(DateTime.Today)) { RawMessage theMsg = MsgRepository.GetMessage("IQTouchImmunisationDate"); RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "src1", "FormValidatedOnSubmit('" + theMsg.Text + "');", true); return(false); } } return(true); }
//==================================== // ClusterApplication //==================================== public override void HandleApplicationMessage(RawMessage message, IApplicationOutboundStream responder) { }
public void HandleApplicationMessage(RawMessage message) => Broadcast(app => app.HandleApplicationMessage(message));
public RawMessage OnProduce(RawMessage rawMessage) { return(rawMessage); }
public void OnMessageUnPublished(RawMessage message) { Log.Error("reportEvent fail: " + message.Payload); }
private void NetworkLoop() { while (!Cancellator.IsCancellationRequested) { try { if (!Socket.Poll(100000, SelectMode.SelectRead)) { continue; } } catch (SocketException) { break; } byte[] Data; try { byte[] Buffer = new byte[8]; Stream.Read(Buffer, 0, 8); int PacketLength = ToInt32(Buffer, 0); if (ToUInt32(Buffer, 4) != 0x31305456U) { break; } Data = new byte[PacketLength]; int Offset = 0; do { int BytesRead = Stream.Read(Data, Offset, PacketLength); if (BytesRead == 0) { break; } Offset += BytesRead; PacketLength -= BytesRead; } while (PacketLength > 0); if (PacketLength != 0) { break; } } catch (IOException) { break; } try { if (State == EncryptionState.Encrypted) { MessageReceived(Encryptor.Decrypt(Data)); } else { MessageType Type = MessageType.Invalid; if (Data.Length > 3) { Type = (MessageType)(ToUInt32(Data, 0) & ~0x80000000U); } if (State == EncryptionState.Connected && Type == MessageType.ChannelEncrypt) { RawMessage <ChannelEncrypt> Message = new RawMessage <ChannelEncrypt>(Data); if (Message.Payload.Length >= 16) { RawMessage <ChannelEncrypt> Response = new RawMessage <ChannelEncrypt>(MessageType.ChannelEncryptResponse); byte[] Challenge = Message.Payload, EncryptedBlob, SessionKey = new byte[32]; using (RandomNumberGenerator RNG = RandomNumberGenerator.Create()) RNG.GetBytes(SessionKey); using (RSA RSA = RSA.Create()) { RSA.ImportParameters(Parameters); byte[] BlobToEncrypt = new byte[32 + Challenge.Length]; Copy(SessionKey, BlobToEncrypt, 32); Copy(Challenge, 0, BlobToEncrypt, 32, Challenge.Length); EncryptedBlob = RSA.Encrypt(BlobToEncrypt, RSAEncryptionPadding.OaepSHA1); } byte[] CRCHash; using (CRC32 CRC = new CRC32()) CRCHash = CRC.ComputeHash(EncryptedBlob); int Length = EncryptedBlob.Length; Response.Payload = new byte[Length + 8]; Copy(EncryptedBlob, Response.Payload, Length); Copy(CRCHash, 0, Response.Payload, Length, 4); Encryptor = new EncryptionFilter(SessionKey); State = EncryptionState.Challenged; Send(Response.Serialize()); } else { Disconnect(false); } } else if (State == EncryptionState.Challenged && Type == MessageType.ChannelEncryptResult) { if (new RawMessage <ChannelEncryptResult>(Data).Body.Success) { State = EncryptionState.Encrypted; Log($"Established encrypted TCP connection to {EndpointAddress}"); Connected?.Invoke(); } else { Disconnect(false); } } else { Disconnect(false); } } } catch { } } bool UserInitiated = Cancellator.IsCancellationRequested; if (UserInitiated) { Shutdown(); } Release(UserInitiated); }
public void OnMessagePublished(RawMessage message) { Log.Debug("reportEvent success: " + message.Payload); }
public void SendToPrimary(RawMessage message) { this.Send(this.primaryQueueName, message); }
public void SendToError(RawMessage message) { this.Send(this.errorQueueName, message); }
public void SendTo(RawMessage message, Id id) { var buffer = _pool.Access(); SendTo(BytesFrom(message, buffer), id); }
public static Error.ErrorType CreateUDPChatMessage(NetworkEntity sender, ChatGroup targetGroup, string bodyMessage, out Message targetMessage) { int bytesToSend = Message.HeaderOfMessageCommand.Length; byte[] rawBuffer = new byte[Server.ServerSettings.ServerBufferSize]; GameClient senderClient; short shortBuffer; targetMessage = null; byte[] messageHeaderContent = null; byte[] bytesBuffer = null; if (sender == null) { return(Error.ErrorType.InvalidNetworkEntity); } if (targetGroup == null) { return(Error.ErrorType.ChatInvalidGroup); } senderClient = (GameClient)sender; ///Writing header System.Buffer.BlockCopy(Message.HeaderOfMessageCommand, 0, rawBuffer, 0, Message.HeaderOfMessageCommand.Length); bytesToSend += 4; ///Writing the command. rawBuffer[bytesToSend] = (byte)Message.CommandType.UDPChat; bytesToSend += 1; ///Writing the hash's length shortBuffer = (short)senderClient.ClientOwner.Hash.Length; bytesBuffer = null; bytesBuffer = System.BitConverter.GetBytes(shortBuffer); System.Buffer.BlockCopy(bytesBuffer, 0, rawBuffer, bytesToSend, bytesBuffer.Length); bytesToSend += bytesBuffer.Length; ///Writing the user's hash code. System.Buffer.BlockCopy(senderClient.ClientOwner.Hash, 0, rawBuffer, bytesToSend, shortBuffer); bytesToSend += shortBuffer; ///Writing the user name length bytesToSend + 2 to make room to the name's length. KSPMGlobals.Globals.StringEncoder.GetBytes(((GameClient)sender).ClientOwner.Username, out bytesBuffer); shortBuffer = (short)bytesBuffer.Length; System.Buffer.BlockCopy(bytesBuffer, 0, rawBuffer, bytesToSend + 2, bytesBuffer.Length); bytesBuffer = System.BitConverter.GetBytes(shortBuffer); System.Buffer.BlockCopy(bytesBuffer, 0, rawBuffer, bytesToSend, bytesBuffer.Length); bytesToSend += bytesBuffer.Length + shortBuffer; ///Writing the groupId. bytesBuffer = System.BitConverter.GetBytes(targetGroup.Id); System.Buffer.BlockCopy(bytesBuffer, 0, rawBuffer, bytesToSend, bytesBuffer.Length); bytesToSend += bytesBuffer.Length; ///Writing the body message. KSPMGlobals.Globals.StringEncoder.GetBytes(bodyMessage, out bytesBuffer); shortBuffer = (short)bytesBuffer.Length; ///bytesToSend + 2 because we have to left room for the size of the messagebody. System.Buffer.BlockCopy(bytesBuffer, 0, rawBuffer, bytesToSend + 2, shortBuffer); ///Writing the body message's size bytesBuffer = System.BitConverter.GetBytes(shortBuffer); System.Buffer.BlockCopy(bytesBuffer, 0, rawBuffer, bytesToSend, bytesBuffer.Length); bytesToSend += shortBuffer + bytesBuffer.Length; ///Writing the EndOfMessage command. System.Buffer.BlockCopy(Message.EndOfMessageCommand, 0, rawBuffer, bytesToSend, Message.EndOfMessageCommand.Length); bytesToSend += Message.EndOfMessageCommand.Length; //Writing the message length. messageHeaderContent = System.BitConverter.GetBytes(bytesToSend); System.Buffer.BlockCopy(messageHeaderContent, 0, rawBuffer, Message.HeaderOfMessageCommand.Length, messageHeaderContent.Length); targetMessage = new RawMessage((Message.CommandType)rawBuffer[Message.HeaderOfMessageCommand.Length + 4], null, (uint)bytesToSend); //targetMessage = new ManagedMessage((Message.CommandType)rawBuffer[Message.HeaderOfMessageCommand.Length + 4], sender); targetMessage.SetBodyMessage(rawBuffer, (uint)bytesToSend); return(Error.ErrorType.Ok); }
public IConsumerByteBuffer BytesFrom(RawMessage message, IConsumerByteBuffer buffer) { message.CopyBytesTo(buffer.Clear().AsStream()); return(buffer.Flip()); }
public void OnRawMessage(RawMessageEventArgs args) { RawMessage?.Invoke(this, args); }
public static void ShowfromPage(string MessageId, Page frmName) { RawMessage theMsg = MsgRepository.GetMessage(MessageId); Showfrompage(theMsg.ToString(), theMsg.Type.ToString(), theMsg.Buttons.ToString(), frmName); }
public RawMessage OnConsume(RawMessage rawMessage) { return(rawMessage); }
public static void Show(string MessageId, Control frmName) { RawMessage theMsg = MsgRepository.GetMessage(MessageId); Show(theMsg.ToString(), theMsg.Type.ToString(), theMsg.Buttons.ToString(), frmName); }
public async Task SendMessageAsync(RawMessage message) { var line = message.ToString(); this._socket.Send(line); }
//========================================= // InboundReaderConsumer //========================================= public void Consume(RawMessage message) { _interest.HandleInboundStreamMessage(_addressType, RawMessage.Copy(message)); }
public override void processMessage(RawMessage message) { UserMe.self.setState(User.UserState.LOBBY); Runner.Graphics.loadLobby(); }
public void Broadcast(IEnumerable <Node> selectNodes, RawMessage message) { var buffer = _pool.Access(); Broadcast(selectNodes, BytesFrom(message, buffer)); }
/// <summary> /// <see cref="Send" /> this message. /// </summary> /// <returns> /// <see langword="true" /> if it succeeds, <see langword="false" /> if it fails. /// </returns> internal bool Send() { _email.MessageId = string.Empty; try { var mailMessage = new MailMessage { From = new MailAddress(_email.FromAddress) }; foreach (string toAddress in _email.ToAddressList) { mailMessage.To.Add(new MailAddress(toAddress)); } foreach (string ccAddress in _email.CcAddressList) { mailMessage.CC.Add(new MailAddress(ccAddress)); } foreach (string bccAddress in _email.BccAddressList) { mailMessage.Bcc.Add(new MailAddress(bccAddress)); } mailMessage.Subject = _email.MessageSubject; mailMessage.SubjectEncoding = Encoding.UTF8; mailMessage.AlternateViews.Add( _email.HTML ? AlternateView.CreateAlternateViewFromString(_email.MessageBody, Encoding.UTF8, "text/html") : AlternateView.CreateAlternateViewFromString(_email.MessageBody, Encoding.UTF8, "text/plain")); var attachment = new Attachment(_email.AttachmentFilePath) { ContentType = new ContentType("application/octet-stream") }; ContentDisposition disposition = attachment.ContentDisposition; disposition.DispositionType = "attachment"; disposition.CreationDate = File.GetCreationTime(_email.AttachmentFilePath); disposition.ModificationDate = File.GetLastWriteTime(_email.AttachmentFilePath); disposition.ReadDate = File.GetLastAccessTime(_email.AttachmentFilePath); mailMessage.Attachments.Add(attachment); var rawMessage = new RawMessage(); using (MemoryStream memoryStream = ConvertMailMessageToMemoryStream(mailMessage)) rawMessage.WithData(memoryStream); var request = new SendRawEmailRequest { RawMessage = rawMessage, Destinations = _email.Destination.ToAddresses, Source = _email.FromAddress }; using (var client = new Client(_email.Credentials)) { _email.MessageId = client.SendRawEmail(request); } return(!_email.ErrorExists); } catch (AmazonSimpleEmailServiceException ex) { return(_email.SetErrorMessage( string.Format( "AWS Simple Email Service Exception\n\nError Type: {0}\n" + "Error Code: {1}\nRequest Id: {2}\nStatus Code: {3}\n\n{4}", ex.ErrorType, ex.ErrorCode, ex.RequestId, ex.StatusCode, ex))); } catch (AmazonClientException ex) { return(_email.SetErrorMessage(ex.ToString())); } catch (Exception ex) { return(_email.SetErrorMessage(ex.ToString())); } }
public void Broadcast(RawMessage message) { var buffer = _pool.Access(); Broadcast(BytesFrom(message, buffer)); }
public void SendTo(RawMessage message, Id targetId) => _outbound.SendTo(message, targetId);
public IEnumerable <byte> GetRdata(ushort len) { return(RawMessage.Skip(Position).Take(len)); }
public void OnMessageUnPublished(RawMessage message) { Console.WriteLine("pubFailMessage:" + message.Payload); Console.WriteLine(); }
public void Send(string subscription, object message) { this.Send(subscription, RawMessage.Create(message)); }
public void Send <T>(string subscription, IMessage <T> message) { this.Send(subscription, RawMessage.Create(message)); }
public void SendToDelay(RawMessage message) { this.Send(this.delayQueueName, message); }