private Task <bool> ProcessFragment(string Xml) { Task <bool> Result; TextEventHandler h = this.OnReceived; if (h is null) { Result = Task.FromResult <bool>(false); } else { try { Result = h(this, Xml); } catch (Exception ex) { Log.Critical(ex); Result = Task.FromResult <bool>(false); } //if (Result && this.callbacks != null) // this.CallCallbacks(); } return(Result); }
private bool ProcessFragment(string Xml) { TextEventHandler h = this.OnReceived; if (h != null) { bool Result; try { Result = h(this, Xml); } catch (Exception ex) { Log.Critical(ex); Result = false; } //if (Result && this.callbacks != null) // this.CallCallbacks(); return(Result); } else { return(false); } }
// Start is called before the first frame update void Start() { TextEvents = GetComponent <TextEventHandler>(); TextEvents.onWordEnter.AddListener(OnWordEnter); TextEvents.onWordLeave.AddListener(OnWordLeave); TextEvents.onLinkEnter.AddListener(OnLinkEnter); TextEvents.onLinkLeave.AddListener(OnLinkLeave); }
private async void Handle(Player player, string text) { var rt = RTVar.Parse(text); var world = await Database.GetWorld(player.CurrentWorld); if (!rt.IsValid()) { return; } var instance = new TextEventHandler() { Player = player, World = world, Data = text, Rt = rt }; var method = instance.GetType() .GetMethods() .FirstOrDefault(x => { var attribute = x.GetCustomAttribute(typeof(TextPacketAttribute)); if (attribute == null) { return(false); } var type = attribute?.GetType(); var textProperty = type?.GetProperty("TextName"); var textValue = textProperty?.GetValue(attribute).ToString(); var lobbyProperty = type?.GetProperty("RequireLobby"); var lobbyValue = (bool)lobbyProperty?.GetValue(attribute); var defaultProperty = type?.GetProperty("DefaultLobby"); var defaultValue = (bool)defaultProperty?.GetValue(attribute); if (!defaultValue) { if (lobbyValue != player.InLobby) { return(false); } } return(textValue != null && text.StartsWith(textValue)); }); //instance.GetType().GetProperty("Rt").SetValue(instance, rt); //instance.GetType().GetProperty("World").SetValue(instance, world); //instance.GetType().GetProperty("Player").SetValue(instance, player); method?.Invoke(instance, null); }
private void RaiseOnReceived(string Payload) { TextEventHandler h = this.OnReceived; if (h != null) { try { h(this, Payload); } catch (Exception ex) { Log.Critical(ex); } } }
private void Peer_OnSent(object Sender, byte[] Packet) { TextEventHandler h = this.OnSent; if (h != null) { try { string s = this.encoding.GetString(Packet); h(this, s); } catch (Exception ex) { Log.Critical(ex); } } }
private async Task <bool> RaiseOnReceived(string Payload) { TextEventHandler h = this.OnReceived; bool Result = true; if (!(h is null)) { try { Result = await h(this, Payload); } catch (Exception ex) { Log.Critical(ex); } } return(Result); }
private Task Peer_OnSent(object Sender, byte[] Buffer, int Offset, int Count) { TextEventHandler h = this.OnSent; if (h != null) { try { string s = this.encoding.GetString(Buffer, Offset, Count); h(this, s); } catch (Exception ex) { Log.Critical(ex); } } return(Task.FromResult <bool>(true)); }
private void Awake() { textEventHandler = GetComponent <TextEventHandler>(); }