public async Task Handle(SendMessageEvent message, CancellationToken cancellationToken) { var playerId = message.PlayerId; var content = message.Content; await _queueHandler.SendQueueMessage(new SaveChatLogQueue(playerId, content)); }
public override void OnEvent(SendMessageEvent evnt) { if (evnt.Target) { evnt.Target.gameObject.SendMessage(evnt.Message); } }
internal override void OnInitialization() { base.OnInitialization(); _helper = Helper as INetworkHelper; _helper.LoadProtocolChannels(ChannelTypes); _helper.BeginConnectServerEvent += (cha) => { BeginConnectServerEvent?.Invoke(cha); }; _helper.ConnectServerSuccessEvent += (cha) => { ConnectServerSuccessEvent?.Invoke(cha); }; _helper.ConnectServerFailEvent += (cha) => { ConnectServerFailEvent?.Invoke(cha); }; _helper.DisconnectServerEvent += (cha) => { DisconnectServerEvent?.Invoke(cha); }; _helper.SendMessageEvent += (cha) => { SendMessageEvent?.Invoke(cha); }; _helper.ReceiveMessageEvent += (cha, mes) => { ReceiveMessageEvent?.Invoke(cha, mes); }; }
public void enableNitrogenExplosion() { if (this.nitrogenActive) { return; } this.nitrogenActive = true; if (BoltNetwork.isRunning && BoltNetwork.isClient) { BoltEntity component = this.parentGo.GetComponent <BoltEntity>(); if (component && component.isAttached) { SendMessageEvent sendMessageEvent = SendMessageEvent.Create(GlobalTargets.OnlyServer); sendMessageEvent.Target = component; sendMessageEvent.Message = "enableNitrogenExplosion"; sendMessageEvent.Send(); } } this.flameGo.SetActive(true); if (!BoltNetwork.isClient) { Rigidbody component2 = this.parentGo.GetComponent <Rigidbody>(); if (component2) { component2.isKinematic = false; component2.useGravity = true; } this.spawnedBomb = UnityEngine.Object.Instantiate <GameObject>(this.ExplodeGo, base.transform.position, base.transform.rotation); this.spawnedBomb.SendMessage("setWaitTime", this.waitTime, SendMessageOptions.DontRequireReceiver); base.Invoke("CleanUp", (float)this.waitTime); } this.nitrogenActive = true; }
private void SendMessageHandler(byte[] data) { SendMessage sendMessage = NetworkUtils.Deserialize <SendMessage>(data); Application.Current.Dispatcher.BeginInvoke(new Action(() => { SendMessageEvent?.Invoke(sendMessage); })); }
/* * A private method which sends the two clients the maze so that they can * start playing it. */ private void SendPlayersMaze() { foreach (KeyValuePair <string, Position> player in players) { string response = maze.toJSON(); JObject json = JObject.Parse(response); SendMessageEvent?.Invoke(player.Key, json); } }
private void SendMessage(string msg) { var timeStamp = DateTime.Now.ToString("[yyyy/MM/dd HH:mm:ss.fff]"); msg = $"[{Thread.CurrentThread.ManagedThreadId}]" + timeStamp + msg; if (SendMessageEvent != null) { SendMessageEvent.Invoke(this, msg); } }
/* * When one player wants to cancel the game, the other user is alerted */ public void CancelGame(string player) { // We get the stream (saved from previously) to send the other player string other = GetOtherPlayer(player); // We send the message if (other != null) { SendMessageEvent?.Invoke(other, null); } }
public void Should_raise_a_SendMessageEvent() { SendMessageEvent sendMessageEvent = null; DomainEvent.TestWith(@event => { sendMessageEvent = (SendMessageEvent)@event; }); child.WithdrawCashFromParent(parent, 2.30M, "For Toys"); sendMessageEvent.ShouldNotBeNull(); sendMessageEvent.User.ShouldBeTheSameAs(parent); sendMessageEvent.Message.ShouldEqual("Leo would like to withdraw �30"); }
/* * This method alerts the second player that the other player has moved */ private void AlertOtherPlayer(string mover, string direction) { // Generate the Json Object to send JObject playerAlert = new JObject(); playerAlert["Name"] = maze.name; playerAlert["Direction"] = direction; // We get the stream (saved from previously) to send the other player string other = GetOtherPlayer(mover); // We send the message SendMessageEvent?.Invoke(other, playerAlert); }
private void Explosion() { if (BoltNetwork.isRunning && this.entity.IsAttached()) { SendMessageEvent sendMessageEvent = SendMessageEvent.Create(GlobalTargets.OnlyServer); sendMessageEvent.Target = this.entity; sendMessageEvent.Message = "ExplosionReal"; sendMessageEvent.Send(); } else { this.ExplosionReal(); } }
internal override void OnInitialization() { base.OnInitialization(); //加载通信协议通道 for (int i = 0; i < ChannelTypes.Count; i++) { Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(ChannelTypes[i]); if (type != null) { if (type.IsSubclassOf(typeof(ProtocolChannelBase))) { if (!_protocolChannels.ContainsKey(type)) { _protocolChannels.Add(type, Activator.CreateInstance(type) as ProtocolChannelBase); } } else { throw new HTFrameworkException(HTFrameworkModule.Network, "加载通信协议通道失败:通信协议通道类 " + ChannelTypes[i] + " 必须实现接口:IProtocolChannel!"); } } else { throw new HTFrameworkException(HTFrameworkModule.Network, "加载通信协议通道失败:丢失通信协议通道类 " + ChannelTypes[i] + "!"); } } //初始化通道 foreach (var channel in _protocolChannels) { channel.Value.OnInitialization(); channel.Value.SendMessageEvent += (cha) => { SendMessageEvent?.Invoke(cha); }; channel.Value.ReceiveMessageEvent += (cha, message) => { ReceiveMessageEvent?.Invoke(cha, message); }; channel.Value.DisconnectServerEvent += (cha) => { DisconnectServerEvent?.Invoke(cha); }; } }
private void HitAxe() { this.Blood(); if (this.Health >= -20 || this.animator.GetBool("deathfinalBOOL")) { } if (EnemyHealth.CurrentAttacker) { SendMessageEvent sendMessageEvent = SendMessageEvent.Raise(EnemyHealth.CurrentAttacker, EntityTargets.OnlyOwner); sendMessageEvent.Message = "GotBloody"; sendMessageEvent.Send(); } else { LocalPlayer.GameObject.SendMessage("GotBloody"); } }
/// <summary> /// 发送消息(不需要保持连接的协议) /// </summary> private void SendMessageNoConnect() { while (_isEnableThread) { if (_isCanSend && _sendDataBuffer.Count > 0) { int sendCount = Client.SendTo(_sendDataBuffer[0], Main.m_Network.ServerEndPoint); if (sendCount > 0) { _sendDataBuffer.RemoveAt(0); Main.Current.QueueOnMainThread(() => { SendMessageEvent?.Invoke(this); }); } } } }
/// <summary> /// 发送消息(需要保持连接的协议) /// </summary> private void SendMessageNeedConnect() { while (_isEnableThread) { if (IsConnect && _isCanSend && _sendDataBuffer.Count > 0) { int sendCount = Client.Send(_sendDataBuffer[0], _sendDataBuffer[0].Length, 0); if (sendCount > 0) { _sendDataBuffer.RemoveAt(0); Main.Current.QueueOnMainThread(() => { SendMessageEvent?.Invoke(this); }); } } } }
/// <summary> /// 加载通信管道 /// </summary> /// <param name="channelTypes">启用的通信协议通道类型</param> public void LoadProtocolChannels(List <string> channelTypes) { for (int i = 0; i < channelTypes.Count; i++) { Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(channelTypes[i]); if (type != null) { if (type.IsSubclassOf(typeof(ProtocolChannelBase))) { if (!ProtocolChannels.ContainsKey(type)) { ProtocolChannels.Add(type, Activator.CreateInstance(type) as ProtocolChannelBase); } } else { throw new HTFrameworkException(HTFrameworkModule.Network, "加载通信协议通道失败:通信协议通道类 " + channelTypes[i] + " 必须继承至基类:ProtocolChannelBase!"); } } else { throw new HTFrameworkException(HTFrameworkModule.Network, "加载通信协议通道失败:丢失通信协议通道类 " + channelTypes[i] + "!"); } } foreach (var channel in ProtocolChannels) { channel.Value.OnInitialization(); channel.Value.SendMessageEvent += (cha) => { SendMessageEvent?.Invoke(cha); }; channel.Value.ReceiveMessageEvent += (cha, message) => { ReceiveMessageEvent?.Invoke(cha, message); }; channel.Value.DisconnectServerEvent += (cha) => { DisconnectServerEvent?.Invoke(cha); }; } }
public async Task Handle(SendMessageEvent message, CancellationToken cancellationToken) { var playerId = message.PlayerId; var content = message.Content; await _queueHandler.SendQueueMessage(new SaveChatLogQueue(playerId, content)); //await _mudProvider.ShowMessage(playerId, $"你说:{content}"); /* * await _chatLogDomainService.Add(new ChatLogEntity * { * PlayerId = playerId, * Content = content, * PostDate = DateTime.Now * }); * * * await Commit(); */ // await _delayedQueue.Publish(new MessageModel { Content = receivedMessage.Content, PlayerId = _account.PlayerId }, 2, 10); }
public void HitReal(int damage) { if (this.hitBlock || this.deadBlock) { return; } if (!base.enabled) { return; } if (this.ai.creepy || this.ai.creepy_male || this.ai.creepy_fat || this.ai.creepy_baby) { this.Health -= damage; if (this.setup.pmCombat) { this.setup.pmCombat.FsmVariables.GetFsmBool("gettingHit").Value = true; this.setup.pmCombat.SendEvent("gotHit"); base.Invoke("resetGettingHit", 1.3f); } if (this.Health < 1) { this.Die(); } else if (this.onFireEventInstance == null) { FMODCommon.PlayOneshot(this.HurtEvent, base.transform.position, new object[] { "mutant_health", this.HealthPercentage }); } return; } if (this.targetSwitcher) { this.targetSwitcher.attackerType = 4; } this.hitBlock = true; base.Invoke("hitBlockReset", 0.25f); if (this.animator.GetBool("deathBOOL")) { this.damageMult = 2; } else { this.damageMult = 1; } if (this.animator.GetBool("sleepBOOL")) { this.Health -= 100; } else { this.Health -= damage * this.damageMult; } if (this.Health <= 80 && this.Health >= 45) { this.animator.SetIntegerReflected("hurtLevelInt", 1); } if (this.Health < 45 && this.Health >= 30) { this.animator.SetIntegerReflected("hurtLevelInt", 2); } if (this.Health < 30 && this.Health >= 1 && this.animator) { this.animator.SetIntegerReflected("hurtLevelInt", 3); } base.Invoke("setMpRandInt", 1f); if (this.Health < 1) { if (this.animator) { this.animator.SetIntegerReflected("hurtLevelInt", 4); } this.setup.pmCombat.enabled = true; this.setup.pmCombat.FsmVariables.GetFsmBool("deathFinal").Value = true; if (this.onFire) { this.animator.SetBoolReflected("burning", true); this.animator.SetBoolReflected("deathBOOL", true); } if (this.animator) { this.animator.SetBoolReflected("deathfinalBOOL", true); } if (!this.doStealthKill && !this.onFire && this.animator) { this.animator.SetIntegerReflected("randInt1", UnityEngine.Random.Range(0, 8)); this.animator.SetTriggerReflected("deathTrigger"); } this.Die(); } else if (this.hitDir == 1) { if (!this.setup.ai.creepy && !this.setup.ai.creepy_male && !this.setup.ai.creepy_fat && !this.setup.ai.creepy_baby && this.setup.search.lookingForTarget && this.doStealthKill) { this.Die(); } else { if (this.animator) { if (this.onFire && !this.hitEventBlock) { this.animator.SetBoolReflected("burning", true); if (!this.animator.GetBool("trapBool")) { this.animator.SetTriggerReflected("damageTrigger"); } } else if (!this.hitEventBlock) { this.animator.SetTriggerReflected("damageBehindTrigger"); this.animator.SetBoolReflected("burning", false); } } if (this.setup.pmCombat) { if (this.onFire && !this.hitEventBlock) { this.setup.pmCombat.enabled = true; this.setup.pmCombat.FsmVariables.GetFsmBool("onFireBool").Value = true; this.setup.pmCombat.SendEvent("gotHit"); this.hitEventBlock = true; } else if (!this.onFire) { this.setup.pmCombat.SendEvent("gotHit"); this.setup.pmCombat.FsmVariables.GetFsmBool("onFireBool").Value = false; } } if (this.setup.pmSearch && this.setup.pmSearch.enabled) { this.setup.pmSearch.SendEvent("gotHit"); } if (this.setup.pmEncounter && this.setup.pmEncounter.enabled) { this.setup.pmEncounter.SendEvent("gotHit"); } } } else if (this.hitDir == 0) { this.doStealthKill = false; if (this.animator) { if (this.simplifyHitsForMp || BoltNetwork.isRunning) { this.animator.SetTriggerReflected("simpleHitTrigger"); } else if (this.onFire && !this.hitEventBlock) { this.animator.SetBoolReflected("burning", true); if (!this.animator.GetBool("trapBool")) { this.animator.SetTriggerReflected("damageTrigger"); } } else if (!this.hitEventBlock) { this.animator.SetBoolReflected("burning", false); this.animator.SetTriggerReflected("damageTrigger"); } } if (this.setup.pmCombat) { this.setup.pmCombat.enabled = true; if (this.onFire && !this.hitEventBlock) { this.setup.pmCombat.enabled = true; this.setup.pmCombat.FsmVariables.GetFsmBool("onFireBool").Value = true; this.setup.pmCombat.SendEvent("gotHit"); this.hitEventBlock = true; } else if (!this.onFire) { this.setup.pmCombat.SendEvent("gotHit"); this.setup.pmCombat.FsmVariables.GetFsmBool("onFireBool").Value = false; } } if (this.setup.pmSearch && this.setup.pmSearch.enabled) { this.setup.pmSearch.SendEvent("gotHit"); } if (this.setup.pmEncounter && this.setup.pmEncounter.enabled) { this.setup.pmEncounter.SendEvent("gotHit"); } } this.Blood(); this.RandomSplurt = UnityEngine.Random.Range(0, 10); if (!this.ai.creepy && !this.ai.creepy_male && !this.ai.maleSkinny && !this.ai.femaleSkinny && !this.ai.pale && !this.ai.creepy_fat && !this.ai.creepy_baby && !this.alreadyBurnt && this.RandomSplurt == 2) { if (this.MP.MyRandom != 0 || this.MySkin) { } if (this.MP.MyRandom != 1 || this.MySkin) { } if (this.MP.MyRandom != 2 || this.MySkin) { } if (this.MP.MyRandom != 3 || this.MySkin) { } if (EnemyHealth.CurrentAttacker) { SendMessageEvent sendMessageEvent = SendMessageEvent.Raise(EnemyHealth.CurrentAttacker, EntityTargets.OnlyOwner); sendMessageEvent.Message = "GotBloody"; sendMessageEvent.Send(); } else { LocalPlayer.GameObject.SendMessage("GotBloody"); } } }
public void OnSendMessageEvent(object sender, ByteArrayEventArgs e) { SendMessageEvent?.Invoke(sender, e); }
protected void Awake() { DeleteMessageCall = new DeleteMessageEvent(); SendMessageCall = new SendMessageEvent(); }
public override void OnEvent(SendMessageEvent evnt) { this.entity.SendMessage(evnt.Message); }
public override void OnEvent(SendMessageEvent evnt) { base.entity.SendMessage(evnt.Message, SendMessageOptions.DontRequireReceiver); }
private void SendMessage(SendMessageEvent args) { args.SendPacket(new ChatMessage2Packet { Message = args.Message }); }
public void InvokeMessage(Message message) { SendMessageEvent?.Invoke(this, message); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("SmallTree") && this.CanHit && this.FireStick) { other.SendMessage("Burn", SendMessageOptions.DontRequireReceiver); } if ((other.gameObject.CompareTag("enemyCollide") || other.gameObject.CompareTag("animalCollide")) && this.CanHit) { this.CanHit = false; base.Invoke("ResetCanHit", this.DelayAmount); if (this.Stick) { other.SendMessage("Hit", SendMessageOptions.DontRequireReceiver); if (base.GetComponent <AudioSource>()) { base.GetComponent <AudioSource>().Play(); } } if (this.Rock) { other.SendMessage("Hit", SendMessageOptions.DontRequireReceiver); if (base.GetComponent <AudioSource>()) { base.GetComponent <AudioSource>().Play(); } } if (this.FireStick) { if (BoltNetwork.isRunning) { BoltEntity componentInParent = other.GetComponentInParent <BoltEntity>(); if (componentInParent && !componentInParent.isOwner) { SendMessageEvent sendMessageEvent = SendMessageEvent.Create(componentInParent, EntityTargets.OnlyOwner); SendMessageEvent sendMessageEvent2 = SendMessageEvent.Create(componentInParent, EntityTargets.OnlyOwner); sendMessageEvent2.Message = "Douse"; sendMessageEvent2.Target = componentInParent; sendMessageEvent2.Send(); sendMessageEvent.Message = "Burn"; sendMessageEvent.Target = componentInParent; sendMessageEvent.Send(); } else { other.SendMessage("Douse", SendMessageOptions.DontRequireReceiver); other.transform.SendMessage("Burn", SendMessageOptions.DontRequireReceiver); } } else { other.SendMessage("Douse", SendMessageOptions.DontRequireReceiver); other.transform.SendMessage("Burn", SendMessageOptions.DontRequireReceiver); } if (base.GetComponent <AudioSource>()) { base.GetComponent <AudioSource>().Play(); } } if (this.FlameThrower) { other.SendMessage("Douse", SendMessageOptions.DontRequireReceiver); other.SendMessage("Burn", SendMessageOptions.DontRequireReceiver); } if (this.Axe) { other.SendMessage("HitAxe", SendMessageOptions.DontRequireReceiver); if (base.GetComponent <AudioSource>()) { base.GetComponent <AudioSource>().Play(); } } } if (other.gameObject.CompareTag("Tree") && this.CanHit && this.Swung && this.Axe) { this.CanHit = false; base.Invoke("ResetCanHit", this.DelayAmount); if (base.GetComponent <AudioSource>()) { this.Audio.SendMessage("PlayAxeHit"); } other.SendMessage("Hit"); } }
public void Jump(int power, string other) { ICommand command = new SendMessageEvent(other, this); Invoker.GetInstance().AddCommand(command); }
/// <summary> /// 发布事件 /// </summary> /// <param name="message"></param> protected void OnUiShowMessage(DataToolsUIMsg message) { SendMessageEvent?.Invoke(message); }