private static void StreamServiceProvider_OnMessageReceived(IChatService svc, IChatMessage msg) { try { Console.WriteLine($"{msg.Sender.DisplayName}: {msg.Message}"); Console.WriteLine("NAME:"); Console.WriteLine(msg.Sender.DisplayName); string[] redeemString = msg.Message.Split(new string[] { "redeemed " }, StringSplitOptions.None); if (msg is TwitchMessage twitchMsg) { int bits = twitchMsg.Bits; if (bits > 0) { StreamlabsEvent streamlabsEvent = new StreamlabsEvent(); streamlabsEvent.type = "bits"; streamlabsEvent.message = new Message[1]; streamlabsEvent.message[0] = new Message(); streamlabsEvent.message[0].name = msg.Sender.UserName; streamlabsEvent.message[0].amount = twitchMsg.Bits.ToString(); unitySyncContext.Send(SafeInvokeNormalStreamEvent, streamlabsEvent); } } if (redeemString.Length > 1) { Console.WriteLine(redeemString[1]); Console.WriteLine(redeemString[0]); Console.WriteLine("REDEEMED ^"); StreamlabsEvent streamlabsEvent = new StreamlabsEvent(); streamlabsEvent.type = "channelpoints"; streamlabsEvent.message = new Message[1]; streamlabsEvent.message[0] = new Message(); streamlabsEvent.message[0].name = redeemString[0].Split(new string[] { "] " }, StringSplitOptions.None)[1].Trim(); streamlabsEvent.message[0].channelPointsName = redeemString[1].Trim(); unitySyncContext.Send(SafeInvokeStreamEvent, streamlabsEvent); /*foreach (CustomAlert alert in AlertObjectLoader.CustomAlerts) * { * if(alert.Descriptor.ChannelPointsName.ToLower().Trim() == redeemString[1].ToLower().Trim()) * { * //StreamlabsEvent labsEvent = new StreamlabsEvent(); * //labsEvent.type = "channelpoints"; * //labsEvent.message[0] = new Message(); * //labsEvent.message[0].name = redeemString[0].Trim(); * //alert.streamEvent = labsEvent; * //Debug.WriteLine(redeemString[0]); * //alert.ChannelPointsUser = redeemString[0].Split(new string[] { "] " }, StringSplitOptions.None)[1].Trim(); * //alert.Spawn * } * }*/ //.streamEvent = streamlabsEvent; } void SafeInvokeStreamEvent(object streamEvent) => OnEvent?.Invoke(streamEvent as StreamlabsEvent); void SafeInvokeNormalStreamEvent(object streamEvent) => OnNormalEvent?.Invoke(streamEvent as StreamlabsEvent); } catch (Exception e) { Console.WriteLine(e); } //Console.WriteLine(msg.ToJson().ToString()); }
public void Send() { if (OnEvent != null) { OnEvent.Invoke(); } }
IEnumerator RunTime() { if (settingTime) { wasRunning = true; yield break; } running = true; for (; currentTime > 0; currentTime--) { yield return(new WaitForSeconds(1)); if (!running) { break; } SecPointer.transform.eulerAngles -= Vector3.forward * 6; MinPointer.transform.eulerAngles -= Vector3.forward / 2f;// /60 * 6 * 5 } if (!running) { yield break; } TimeUp.Invoke(); running = false; yield break; }
public void FireEvent(T evtId, params object[] args) { OnEventFire?.Invoke(evtId, args); if (!EventProcessorDic.ContainsKey(evtId)) { return; } if (EventProcessorDic[evtId] == null && EventProcessorDic[evtId].Count == 0) { EventProcessorDic.Remove(evtId); return; } List <OnEvent> list = EventProcessorDic[evtId]; for (int i = 0; i < list.Count; i++) { OnEvent del = list[i]; if (del.Target is IEventObserver) { if ((del.Target as IEventObserver).IsObserverAlive()) { del(evtId, args); } else { list.RemoveAt(i--); } } else { del(evtId, args); } } }
protected override void Dispatch(string message) { var jObject = Newtonsoft.Json.Linq.JObject.Parse(message); var type = jObject.Value <string>("type"); if (type == "response") { var success = jObject.Value <bool>("success"); var request_seq = jObject.Value <int>("request_seq"); var request = Requests[request_seq]; if (success) { request.ObjectBody = jObject.GetValue("body").ToObject(request.GetResponseBodyType()); } else { request.ErrorMessage = jObject.Value <string>("message"); } //if (Trace.HasFlag(TraceLevel.Responses)) // Console.Error.WriteLine(string.Format("R {0}: {1}", response.command, JsonConvert.SerializeObject(response.body))); } else if (type == "event") { OnEvent?.Invoke(JsonConvert.DeserializeObject <Event>(message)); } }
static public void Trigger(AnimationCurve intensity, float duration, float remapMin, float remapMax, AnimationCurve threshold, float remapThresholdMin, float remapThresholdMax, bool relativeIntensity = false, float feedbacksIntensity = 1.0f, int channel = 0, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled) { OnEvent?.Invoke(intensity, duration, remapMin, remapMax, threshold, remapThresholdMin, remapThresholdMax, relativeIntensity, feedbacksIntensity, channel, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode); }
protected override async Task OnActionAsync(CustomOperation value) { switch (_operationCode) { //case OperationCodes.QueryGuildPlayerStats: //case OperationCodes.CastCancel: // координаты и поворот //case OperationCodes.ChannelingCancel: // атака //case OperationCodes.TerminateToggleSpell: // атака // break; default: if (value.Parameters.Any(p => { if (!Utils.TryToInt(p.Value, out var i)) { return(false); } return(i == 2096); })) { Debug.WriteLine($"-------------- Operation {_operationCode} -----------------"); foreach (var pair in value.Parameters) { Debug.WriteLine(pair.Key + ": " + Utils.ToString(pair.Value)); } } break; } OnEvent?.Invoke(_operationCode, value.Parameters); }
//----------------------------------------------------------- /// <summary> /// Function to post event to listeners /// </summary> /// <param name="Event_Type">Event to invoke</param> /// <param name="Sender">Object invoking event</param> /// <param name="Param">Optional argument</param> public void PostNotification(EVENT_TYPE Event_Type, Component Sender, object Param = null) { //Notify all listeners of an event //List of listeners for this event only OnEvent delegateListener = null; //If no event entry exists, then exit because there are no listeners to notify if (!Listeners.TryGetValue(Event_Type, out delegateListener)) { return; } //Entry exists. Now notify appropriate listeners if (delegateListener != null) { delegateListener.Invoke(Sender, Param); } //Entry exists. Now notify appropriate listeners //for (int i = 0; i < ListenList.Count; i++) //{ // if (!ListenList[i].Equals(null)) //If object is not null, then send message via interfaces // ListenList[i](Event_Type, Sender, Param); //} }
public void OnPointerEnter(PointerEventData eventData) { if (eventData.button == Button) { OnEvent.Invoke(); } }
//2["event",{"type":"follow","message":[{"name":"bobbievr","isTest":true,"_id":"3db6e911084bf89505e1118023e985c9","priority":10}],"for":"twitch_account","event_id":"evt_fb97a212e48fb866cacd1cf6c5d24d4f"}] private static void HandleSocketMessage(object sender, MessageEventArgs evt) { try { //if (settings.EmitDebugMessages) Debug.Log("Message: " + evt.Data); var code = evt.Data[0]; var data = evt.Data.Substring(1); if (code == '0') // socket.io ping-pong heartbeat { heartbeatTCS?.Cancel(); heartbeatTCS = new CancellationTokenSource(); var interval = JsonUtility.FromJson <HandshakeResponse>(data).pingTimeout; WebSocketHeartbeatRoutine(interval, heartbeatTCS.Token); return; } if (evt.Data.Contains("event")) { string splitData = evt.Data.Split(new string[] { "\"event\"" }, StringSplitOptions.None)[1].Substring(1); splitData = splitData.Remove(splitData.Length - 1); Console.WriteLine(splitData); StreamlabsEvent streamlabsEvent = JsonConvert.DeserializeObject <StreamlabsEvent>(splitData); unitySyncContext.Send(SafeInvokeStreamEvent, streamlabsEvent); } Console.WriteLine(data); } catch (Exception e) { UnityEngine.Debug.LogWarning($"WebSocket handle message fail: {e.Message}"); } void SafeInvokeStreamEvent(object streamEvent) => OnEvent?.Invoke(streamEvent as StreamlabsEvent); }
/// <summary> /// Handles watching the given key for /// </summary> /// <param name="myCurrentState"></param> /// <param name="myPrevState"></param> /// <param name="key"></param> public void Watch(KeyboardState myCurrentState, KeyboardState myPrevState) { bool wasPressed = myPrevState.IsKeyDown(myKey); bool isPressed = myCurrentState.IsKeyDown(myKey); ButtonDelta deltaState = isPressed != wasPressed ? isPressed ? ButtonDelta.Pressed : ButtonDelta.Released : isPressed ? ButtonDelta.Down : ButtonDelta.Up; if (deltaState == ButtonDelta.Pressed) { OnPressed?.Invoke(this, new KeyPressEventArgs(myKey, deltaState)); } if (deltaState == ButtonDelta.Released) { OnReleased?.Invoke(this, new KeyPressEventArgs(myKey, deltaState)); } if (deltaState == ButtonDelta.Down) { OnDown?.Invoke(this, new KeyPressEventArgs(myKey, deltaState)); } if (deltaState == ButtonDelta.Up) { OnUp?.Invoke(this, new KeyPressEventArgs(myKey, deltaState)); } OnEvent?.Invoke(this, new KeyPressEventArgs(myKey, deltaState)); }
static public void Trigger(AnimationCurve intensity, float duration, float remapMin, float remapMax, AnimationCurve threshold, float remapThresholdMin, float remapThresholdMax, bool relativeIntensity = false, float attenuation = 1.0f, int channel = 0, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true) { OnEvent?.Invoke(intensity, duration, remapMin, remapMax, threshold, remapThresholdMin, remapThresholdMax, relativeIntensity, attenuation, channel, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection); }
public void Foo(string msg) { if (OnEvent != null) { OnEvent.Invoke(this, msg); } }
private void OnSocketMessageReceived(Assembly assembly, string message) { try { var code = message[0]; var data = message.Substring(1); if (code == '0') // socket.io ping-pong heartbeat { _heartbeatCancellationToken?.Cancel(); _heartbeatCancellationToken = new CancellationTokenSource(); var interval = JsonConvert.DeserializeObject <HandshakeResponse>(data).PingTimeout; WebSocketHeartbeatRoutine(interval, _heartbeatCancellationToken.Token); return; } if (message.Contains("event")) { string splitData = message.Split(new string[] { "\"event\"" }, StringSplitOptions.None)[1].Substring(1); splitData = splitData.Remove(splitData.Length - 1); StreamlabsEvent streamlabsEvent = JsonConvert.DeserializeObject <StreamlabsEvent>(splitData); Plugin.Log.Info(splitData); _synchronizationContext.Send(SafeInvokeStreamEvent, streamlabsEvent); } } catch (Exception e) { Plugin.Log.Warn($"Streamlabs message handler failed! {e.Message}"); } void SafeInvokeStreamEvent(object se) => OnEvent?.Invoke(se as StreamlabsEvent); }
private async Task WatcherLoop(CancellationToken cancellationToken) { try { Watching = true; await foreach (var(t, evt) in CreateWatchEventEnumerator(_streamReaderCreator, OnError, cancellationToken) .ConfigureAwait(false) ) { OnEvent?.Invoke(t, evt); } } catch (OperationCanceledException) { // ignore } catch (Exception e) { // error when transport error, IOException ect OnError?.Invoke(e); } finally { Watching = false; OnClosed?.Invoke(); } }
private void Trigger(object str) { if (OnEvent != null) { OnEvent.Invoke(str); } }
private void RangerOnEventHandler(object o, TriggerEventArgs e) { if (!events.ContainsKey(e.Timespan)) { events.Add(e.Timespan, e.Type); OnEvent?.Invoke(this, e); } }
static public void Trigger(AnimationCurve temperature, float duration, float remapTemperatureMin, float remapTemperatureMax, AnimationCurve tint, float remapTintMin, float remapTintMax, bool relativeValues = false, float attenuation = 1.0f, int channel = 0, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true) { OnEvent?.Invoke(temperature, duration, remapTemperatureMin, remapTemperatureMax, tint, remapTintMin, remapTintMax, relativeValues, attenuation, channel, resetShakerValuesAfterShake, resetTargetValuesAfterShake); }
static public void Trigger(AnimationCurve temperature, float duration, float remapTemperatureMin, float remapTemperatureMax, AnimationCurve tint, float remapTintMin, float remapTintMax, bool relativeValues = false, float attenuation = 1.0f, int channel = 0, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false) { OnEvent?.Invoke(temperature, duration, remapTemperatureMin, remapTemperatureMax, tint, remapTintMin, remapTintMax, relativeValues, attenuation, channel, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop); }
private void OnUsageNotification(string value) { OnEvent?.Invoke(async transport => { await transport.WriteInt32(Message.MagicNumber); await transport.WriteMessageType(Message.Type.Event); await transport.WriteInt32((int)CalculatorClient.Event.UsageNotification); await transport.WriteString(value); }); }
public static void Info(string message) { OnEvent?.Invoke(null, new LogEventArgs { Message = message, Time = DateTime.Now }); var now = DateTime.Now; System.Diagnostics.Debug.WriteLine($"LOGGER [{now}.{now.Millisecond}] " + message); }
public bool AddGhost(Ghost ghost) { if (ghostList.Count >= inventorySpace) { return(false); } hadGhosts = true; ghostList.Add(ghost); if (OnEventCallback != null) { OnEventCallback.Invoke(); } return(true); }
internal void RaiseEvent() { OnEvent?.Invoke(this, EventArgs.Empty); EventCallback?.Invoke(); if (_period == BlockerPeriod.Once) { Remove?.Invoke(); } }
public void spinSlotMachineButton() { if (!isSpinning) { onSpin?.Invoke(); reelSpinnerManager.spinReels(); reelSpinnerManager.stopAnimateReels(); StartCoroutine(beginStopSpin()); } }
static public void Trigger(float shakeDuration, bool modifyColor, Gradient colorOverTime, bool flipX, bool flipY, float attenuation = 1.0f, int channel = 0, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool useRange = false, float eventRange = 0f, Vector3 eventOriginPosition = default(Vector3)) { OnEvent?.Invoke(shakeDuration, modifyColor, colorOverTime, flipX, flipY, attenuation, channel, resetShakerValuesAfterShake, resetTargetValuesAfterShake, useRange, eventRange, eventOriginPosition); }
public override void ProcessEventData(JToken data) { var msgId = data.Value <int>("message_id"); var usrId = data.Value <int>("user_id"); OnEvent?.Invoke(new EditedMessage { Message = msgId, EditedBy = usrId }); }
/// <summary> /// This method is called after an event has been processed. /// It will be passed to any event listeners for additional processing. /// </summary> /// <param name="eventData">The event data.</param> protected virtual void RaiseEvent(EventHolder eventData) { try { OnEvent?.Invoke(this, eventData); } catch (Exception) { //No exceptions here } }
static public void Trigger(AnimationCurve focusDistance, float duration, float remapFocusDistanceMin, float remapFocusDistanceMax, AnimationCurve aperture, float remapApertureMin, float remapApertureMax, AnimationCurve focalLength, float remapFocalLengthMin, float remapFocalLengthMax, bool relativeValues = false, float attenuation = 1.0f, int channel = 0, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true) { OnEvent?.Invoke(focusDistance, duration, remapFocusDistanceMin, remapFocusDistanceMax, aperture, remapApertureMin, remapApertureMax, focalLength, remapFocalLengthMin, remapFocalLengthMax, relativeValues, attenuation, channel, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection); }
public override void ProcessEventData(JToken data) { var msgId = data.Value <int>("message_id"); var deletedBy = data.Value <int>("user_id"); OnEvent?.Invoke(new DeletedMessage { DeletedBy = deletedBy, MessageId = msgId }); }
private void SetupSession() { session = new TraceEventSession("DelphiTestProvider"); // ETW buffers events and only delivers them after buffering up for some amount of time. Thus // there is a small delay of about 2-4 seconds between the timestamp on the event (which is very // accurate), and the time we actually get the event. session.Source.Dynamic.All += delegate(TraceEvent data) { Interlocked.Increment(ref EventCounter); var str = data.ToString(); Debug.WriteLine(string.Format("GOT Event {0} ", str)); OnEventAny?.Invoke(this, data.ToString()); }; session.Source.Dynamic.AddCallbackForProviderEvent("Delphi-Test-Provider", "Test/Random", delegate(TraceEvent data) { var index = Interlocked.Increment(ref EventCounter); try { var obj = new TestEventData(index, data); Debug.WriteLine(obj); OnEvent?.Invoke(this, obj); } catch (Exception ex) { Debug.WriteLine("Exception while parsing event: " + ex); } }); session.Source.UnhandledEvents += delegate(TraceEvent data) { if ((int)data.ID != 0xFFFE) // The EventSource manifest events show up as unhanded, filter them out. { Debug.WriteLine("GOT UNHANDLED EVENT: " + data.Dump()); } }; var traceOptions = new TraceEventProviderOptions { StacksEnabled = false }; session.EnableProvider("Delphi-Test-Provider", options: traceOptions); // go into a loop processing events can calling the callbacks. Because this is live data (not from a file) // processing never completes by itself, but only because someone called 'source.Dispose()'. Task.Run(() => { session.Source.Process(); }); }