コード例 #1
0
 /// <summary>
 /// Used to register a method to be executed when the event is fired.
 /// </summary>
 /// <param name="callback">The method to call</param>
 /// <returns>A reference to the event</returns>
 public static OnCommandLoaded Register(OnCall callback)
 {
     Logger.Log("OnCommandLoaded registered to the method " + callback.Method.Name, LogType.Debug);
     OnCommandLoaded pe = new OnCommandLoaded(callback);
     _eventQueue.Add(pe);
     return pe;
 }
コード例 #2
0
        private async Task <IList <UserOnCall> > GetUsersFromOnCall(OnCall onCall, List <OnCallUsersResource> users, CancellationToken cancellationToken)
        {
            var userDtos = await _userRepository.GetAll(cancellationToken);

            var results = new List <UserOnCall>();

            foreach (var user in users)
            {
                var userDto = userDtos.FirstOrDefault(
                    u => u.Username == user.OnCallUser.Username);
                if (userDto == null)
                {
                    continue;
                }

                results.Add(new UserOnCall
                {
                    UserId   = userDto.Id,
                    User     = userDto,
                    OnCallId = onCall.Id,
                    OnCall   = onCall
                });
            }

            return(results);
        }
コード例 #3
0
        private async Task UpdateOnCall(CancellationToken cancellationToken)
        {
            _logger.LogInformation(
                $"VictorOpsTaskHandler.UpdateOnCall was called");
            var currentOnCall = await _onCallService.GetCurrentOnCall(cancellationToken);

            foreach (var teamOnCall in currentOnCall.TeamsOnCall)
            {
                var voTeam = teamOnCall.Team;
                var team   = await _teamRepository.Get(voTeam.Slug, cancellationToken);

                if (team == null)
                {
                    continue;
                }

                foreach (var onCall in teamOnCall.OnCallNow)
                {
                    var onCallDto = new OnCall
                    {
                        Id = $"{voTeam.Name}_{onCall.EscalationPolicy.Slug}",
                        EscalationPolicyName = onCall.EscalationPolicy.Name,
                        Team = team,
                    };
                    onCallDto.Users = await GetUsersFromOnCall(onCallDto, onCall.Users, cancellationToken);

                    await _onCallRepository.UpdateOrCreate(onCallDto, cancellationToken);
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Register this event
 /// The method name must be PlayerConnectEvent
 /// </summary>
 /// <param name="method">The method that will be called when the event is executed</param>
 /// <param name="priority">The priority of the call</param>
 public static void Register(OnCall method, Priority priority)
 {
     Cache r = new Cache();
     r.e = new OnPlayerChatEvent();
     r.method = method;
     r.priority = priority;
     r.Push();
 }
コード例 #5
0
 public void Call(ulong acceptor)
 {
     if (CheckOperator())
     {
         Console.WriteLine("Called {0} from {1}", acceptor, Number);
         OnCall?.Invoke(this, new MobileAccountEventArgs(acceptor));
     }
 }
コード例 #6
0
        /// <summary>
        /// Register this event
        /// The method name must be PlayerConnectEvent
        /// </summary>
        /// <param name="method">The method that will be called when the event is executed</param>
        /// <param name="priority">The priority of the call</param>
        public static void Register(OnCall method, Priority priority)
        {
            Cache r = new Cache();

            r.e        = new OnPlayerConnectEvent();
            r.method   = method;
            r.priority = priority;
            r.Push();
        }
コード例 #7
0
ファイル: TaskDuplication.cs プロジェクト: rick-kim/Algorithm
        private int Calculate(int allCount, int chosenCount)
        {
            OnCall?.Invoke(allCount, chosenCount);

            if (allCount == chosenCount || chosenCount == 0)
            {
                return(1);
            }

            return(Calculate(allCount - 1, chosenCount) + Calculate(allCount - 1, chosenCount - 1));
        }
コード例 #8
0
 /// <summary>
 /// Register this event
 /// </summary>
 /// <param name="method">The method that will be called when the event is executed</param>
 /// <param name="priority">The priority of the call</param>
 public static void Register(OnCall method, Priority priority)
 {
     Registered r = new Registered();
     System.Reflection.ParameterInfo p = method.Method.GetParameters()[0];
     if (p.GetType() == typeof(PlayerConnectEvent))
         r.e = new PlayerConnectEvent();
     else
         throw new Exception("Invalid method");
     r.method = method;
     r.priority = priority;
     r.GiveMuffinToDerpy();
 }
コード例 #9
0
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.O))
        {
            OnCallSound?.Invoke();
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            OnCall?.Invoke(1, 1f);
        }
    }
コード例 #10
0
 public void BtnExplore_Click(EventContext ev, OnCall call)
 {
     DOTween.Kill(this);
     this.call      = call;
     this.touchable = false;
     this.visible   = true;
     this.TweenMoveX(ModelManager.inst.gameModel.width - 209, 0.5f).OnComplete(() =>
     {
         TimerManager.inst.Add(60, 1, onTimersFun);
         this.touchable = true;
     });
 }
コード例 #11
0
 private void OnOverFunction()
 {
     DOTween.Kill(this);
     this.TweenMoveX(ModelManager.inst.gameModel.width, 0.5f).OnComplete(() =>
     {
         if (this.call != null)
         {
             call();
         }
         this.call    = null;
         this.visible = false;
         Tools.Clear(boxBoom);
     });
 }
コード例 #12
0
        public void Call(int number)
        {
            if (Monay >= MobileOperator.CallCost)
            {
                Console.WriteLine("Call to {0}", number);

                OnCall?.Invoke(number, _number);
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("You have not enought money to make call");
                Console.ResetColor();
            }
        }
コード例 #13
0
 /// <summary>
 /// Used to register a method to be executed when the event is fired.
 /// </summary>
 /// <param name="callback">The method to call</param>
 /// <param name="target">The player to watch for. (null for any players)</param>
 /// <returns>the new OnPlayerConnect event</returns>
 public static OnPlayerConnect Register(OnCall callback, Player target)
 {
     Logger.Log("OnPlayerConnect registered to the method " + callback.Method.Name, LogType.Debug);
     //We add it to the list here
     OnPlayerConnect pe = _eventQueue.Find(match => (match.Player == null ? target == null : target != null && target.Username == match.Player.Username));
     if (pe != null)
         //It already exists, so we just add it to the queue.
         pe._queue += callback;
     else {
         //Doesn't exist yet.  Make a new one.
         pe = new OnPlayerConnect(callback, target);
         _eventQueue.Add(pe);
     }
     return pe;
 }
コード例 #14
0
 /// <summary>
 /// Used to register a method to be executed when the event is fired.
 /// </summary>
 /// <param name="callback">The method to call</param>
 /// <param name="target">The level to watch for. (null for any level)</param>
 /// <returns>A reference to the event</returns>
 public static OnLevelSave Register(OnCall callback, Level target)
 {
     Logger.Log("OnLevelSave registered to the method " + callback.Method.Name, LogType.Debug);
     //We add it to the list here
     OnLevelSave pe = _eventQueue.Find(match => match.level == null);
     if (pe != null)
         //It already exists, so we just add it to the queue.
         pe._queue += callback;
     else {
         //Doesn't exist yet.  Make a new one.
         pe = new OnLevelSave(callback, target);
         _eventQueue.Add(pe);
     }
     return pe;
 }
コード例 #15
0
        /// <summary>
        /// Register this event
        /// </summary>
        /// <param name="method">The method that will be called when the event is executed</param>
        /// <param name="priority">The priority of the call</param>
        public static void Register(OnCall method, Priority priority)
        {
            Registered r = new Registered();

            System.Reflection.ParameterInfo p = method.Method.GetParameters()[0];
            if (p.GetType() == typeof(PlayerConnectEvent))
            {
                r.e = new PlayerConnectEvent();
            }
            else
            {
                throw new Exception("Invalid method");
            }
            r.method   = method;
            r.priority = priority;
            r.GiveMuffinToDerpy();
        }
コード例 #16
0
        private int Calculate(int allCount, int chosenCount)
        {
            if (chosenCount == 0 || allCount == chosenCount)
            {
                return(1);
            }

            var savedValue = _cache[allCount, chosenCount];

            if (savedValue > -1)
            {
                OnCache?.Invoke(allCount, chosenCount);
                return(savedValue);
            }

            OnCall?.Invoke(allCount, chosenCount);
            return(_cache[allCount, chosenCount] = Calculate(allCount - 1, chosenCount) + Calculate(allCount - 1, chosenCount - 1));
        }
コード例 #17
0
 private void onTimersFun(float time)
 {
     if (ModelManager.inst.alertModel.isTip && ModelManager.inst.alertModel.type == Config.TOUCH_PROGRESSBAR)
     {
         OnMainExploreFush();
         Log.debug("aaa");
         return;
     }
     DOTween.Kill(this);
     this.touchable = false;
     this.TweenMoveX(ModelManager.inst.gameModel.width, 1f).OnComplete(() =>
     {
         call();
         this.call    = null;
         this.visible = false;
         Tools.Clear(boxBoom);
     });
 }
コード例 #18
0
        public void Call(object acceptor)
        {
            if (!CheckOperator())
            {
                return;
            }
            var phoneBookContact = acceptor as MobileAccount;

            foreach (var contact in phonebook)
            {
                if (contact == phoneBookContact)
                {
                    Console.WriteLine("Called {0} from {1}", phoneBookContact.Name, Number);
                    OnCall?.Invoke(this, new MobileAccountEventArgs(phoneBookContact.Number));
                    return;
                }
            }
            Console.WriteLine("contact is not in phone book");
        }
コード例 #19
0
        private int Calculate(int allCount, int chosenCount)
        {
            for (int i = 0; i <= allCount; i++)
            {
                for (int k = 0; k <= chosenCount && k <= i; k++)
                {
                    if (k == 0)
                    {
                        _cache[i, k] = 1;
                    }
                    else
                    {
                        _cache[i, k] = _cache[i - 1, k] + _cache[i - 1, k - 1];
                    }
                    OnCall?.Invoke(i, k);
                }
            }

            return(_cache[allCount, chosenCount]);
        }
コード例 #20
0
 public void Call(MobileAccount phoneBookContact)
 {
     if (CheckOperator())
     {
         bool isFound = false;
         foreach (var contact in phonebook)
         {
             if (contact.Value == phoneBookContact)
             {
                 Console.WriteLine("Called {0} from {1}", phoneBookContact.name, number);
                 OnCall?.Invoke(this, new MobileAccountEventArgs(phoneBookContact.number));
                 isFound = true;
             }
         }
         if (!isFound)
         {
             Console.WriteLine("contact is not in phone book");
         }
     }
 }
コード例 #21
0
        public void Call(int number)
        {
            Console.WriteLine("Call to {0}", number);

            OnCall?.Invoke(number, _number);
        }
コード例 #22
0
 public ParticipantDeletedTask(GoHereWithSituationEx sit, Sim sim, OnCall func)
 {
     mSituation = sit;
     mSim       = sim;
     mFunc      = func;
 }
コード例 #23
0
 /// <summary>
 /// Register this event
 /// </summary>
 /// <param name="method">The method to call when this event gets excuted</param>
 /// <param name="priority">The importance of the call</param>
 public static void Register(OnCall method, Priority priority, object passdata = null, Player target = null)
 {
     Muffins temp = new Muffins(method, priority, new OnPlayerChat(), passdata, target);
     Muffins.GiveDerpyMuffins(temp);
 }
コード例 #24
0
ファイル: Port.cs プロジェクト: tolpawsta/ATSApp
 public void Coll(int targerPhoneNumber)
 {
     CurrentCallInfo = new CallInfo(PhoneNumber, targerPhoneNumber);
     State           = PortState.Busy;
     OnCall?.Invoke(CurrentCallInfo);
 }
コード例 #25
0
 internal OnCommandLoaded(OnCall callback)
 {
     _queue += callback;
 }
コード例 #26
0
        private void ThreadEventDispatch()
        {
            while (false == EventStop.Wait(1))
            {
                string json   = "";
                bool   pop_ok = EventJsonQueue.TryDequeue(out json);

                if (!pop_ok || json == null || json == "")
                {
                    continue;
                }

                OnEventRawString?.Invoke(this, json);

                JObject    jdata = null;
                EVENT_TYPE type  = ParseEventType(json, out jdata);

                //因為必須在conference裡面中轉各個customized header,不得已只好自己維護live channel的資料...
                //收到CHANNEL_CREATE事件時就收錄channel資訊
                //留在Conference Create時撈出來看 variable_sip_h_X-* 變數....
                switch (type)
                {
                case EVENT_TYPE.CALL_TO_SWITCH:
                    OnCall?.Invoke(this, new CCallEvent(jdata));
                    break;

                case EVENT_TYPE.SWITCH_CALL_USER:
                    OnCall?.Invoke(this, new CCallEvent(jdata));
                    break;

                case EVENT_TYPE.ANSWER:
                    OnAnswer?.Invoke(this, new CAnswerEvent(jdata));
                    break;

                case EVENT_TYPE.HANGUP:
                    OnHangUp?.Invoke(this, new CHangUpEvent(jdata));
                    break;

                case EVENT_TYPE.DESTROY_CALL:
                    OnCallDestroy?.Invoke(this, new CCallEvent(jdata));
                    break;

                case EVENT_TYPE.CONFERENCE_CREATE:
                    OnRoomCreate?.Invoke(this, new CConferenceCreateEvent(jdata));
                    break;

                case EVENT_TYPE.CONFERENCE_DELETE:
                    OnRoomDelete?.Invoke(this, new CConferenceDeleteEvent(jdata));
                    break;

                case EVENT_TYPE.JOIN_CONFERENCE:
                    OnJoinRoom?.Invoke(this, new CJoinConferenceEvent(jdata));
                    break;

                case EVENT_TYPE.LEAVE_CONFERENCE:
                    OnLeaveRoom?.Invoke(this, new CLeaveConferenceEvent(jdata));
                    break;

                case EVENT_TYPE.REGISTER:
                    OnSipRegister?.Invoke(this, new CSipRegister(jdata));
                    break;

                default:
                    Log.Warn($"Unsupported event type {type.ToString()}, skip it...");
                    break;
                }
            }

            //Queue沒有Clear(),只能用這種蠢方法清除
            while (EventJsonQueue.Count > 0)
            {
                string msg = "";
                EventJsonQueue.TryDequeue(out msg);
            }
        }
コード例 #27
0
ファイル: MenuBase.cs プロジェクト: cjburkey01/PlatformerGame
		public MenuOption(Text obj, OnCall onCall) {
			text = obj.text;
			color = obj.color;
			textObj = obj;
			this.onCall = onCall;
		}
コード例 #28
0
 public static void Register(OnCall method, Priority priority)
 {
     EventHelper temp = new EventHelper(method, priority, new OnPlayerConnect());
     EventHelper.Push(temp);
 }
コード例 #29
0
 /// <summary>
 /// Creates a new event.  This is NOT meant to be used by user-code, only internally by events.
 /// </summary>
 /// <param name="callback">the method used for the delegate to callback upon event fire</param>
 /// <param name="target">The target Player we want the event for.</param>
 internal OnPlayerCommand(OnCall callback, Player target)
     : base(target)
 {
     _queue += callback;
 }
コード例 #30
0
 /// <summary>
 /// Creates a new event.  This is NOT meant to be used by user-code, only internally by events.
 /// </summary>
 /// <param name="callback">the method used for the delegate to callback upon event fire</param>
 /// <param name="target">The target Player we want the event for.</param>
 /// <param name="datapass">The data we want to pass between events.</param>
 internal OnPlayerBlockChange(OnCall callback, Player target, object datapass)
     : base(target)
 {
     this.datapass = datapass;
     _queue += callback;
 }
コード例 #31
0
 /// <summary>
 /// Creates a new event.  This is NOT meant to be used by user-code, only internally by events.
 /// </summary>
 /// <param name="callback">the method used for the delegate to callback upon event fire</param>
 /// <param name="target">The target Player we want the event for.</param>
 internal OnPlayerDisconnect(OnCall callback, Player target)
     : base(target)
 {
     _queue += callback;
 }
コード例 #32
0
 /// <summary>
 /// Creates a new event.  This is NOT meant to be used by user-code, only internally by events.
 /// </summary>
 /// <param name="callback">the method used for the delegate to callback upon event fire</param>
 /// <param name="target">The target Player we want the event for.</param>
 private OnPlayerMove(OnCall callback, Player target)
     : base(target)
 {
     _queue += callback;
 }
コード例 #33
0
 /// <summary>
 /// Creates a new event.  This is NOT meant to be used by user-code, only internally by events.
 /// </summary>
 /// <param name="callback">the method used for the delegate to callback upon event fire</param>
 /// <param name="target">The target Level we want the event for.</param>
 private OnLevelSave(OnCall callback, Level target)
     : base(target)
 {
     _queue += callback;
 }
コード例 #34
0
 public virtual void Call()
 {
     OnCall?.Invoke();
 }
コード例 #35
0
 /// <summary>
 /// Register this event
 /// </summary>
 /// <param name="method">The method to call when this event gets excuted</param>
 /// <param name="priority">The importance of the call</param>
 public static void Register(OnCall method, Priority priority, object datapass = null, Player target = null)
 {
     Muffins temp = new Muffins(method, priority, new OnPlayerCommand(), datapass, target);
     Muffins.GiveDerpyMuffins(temp);
 }