Exemplo n.º 1
0
        public void TakeIncomingCall(object sender, CallEvent e)
        {
            bool flag = true;

            Id = e.Id;
            Console.WriteLine("Have incoming Call at number: {0} to terminal {1}", e.TelephoneNumber, e.CalledTelephoneNumber);
            while (flag)
            {
                Console.WriteLine("Answer? Y/N");
                char k = Console.ReadKey().KeyChar;
                if (k == 'Y' || k == 'y')
                {
                    flag = false;
                    Console.WriteLine();
                    this.AnswerToCall(e.TelephoneNumber, CallState.Answered, e.Id);
                }
                else if (k == 'N' || k == 'n')
                {
                    flag = false;
                    Console.WriteLine();
                    this.EndCall();
                }
                else
                {
                    flag = true;
                    Console.WriteLine();
                }
            }
        }
Exemplo n.º 2
0
    public static void ShareShot(string param)
    {
        GameObject main = GameObject.Find("main");
        CallEvent  e    = main.GetComponent <CallEvent>();

        e.ShareShot(param);
    }
Exemplo n.º 3
0
 public void MakeCall(PhoneNumber phoneNumber)
 {
     if (CallEvent != null)
     {
         CallEvent.Invoke(this, phoneNumber);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Добавляет событие
        /// </summary>
        public CallEvent AddCallEvent(CallEvent callEvent)
        {
            db.CallEvents.Add(callEvent);
            db.SaveChanges();

            return(callEvent);
        }
Exemplo n.º 5
0
 public void MakeCall(int number)
 {
     if (CallEvent != null)
     {
         CallEvent.Invoke(this, number);
     }
 }
Exemplo n.º 6
0
    public static void CallFun(string param)
    {
        GameObject main = GameObject.Find("main");
        CallEvent  e    = main.GetComponent <CallEvent>();

        e.CallFun(param);
    }
Exemplo n.º 7
0
        public void raiseEvent(Event evt)
        {
            if (evt == null)
            {
                logwrite.write("raiseEvent", ":::::::::::::::::::::::: evt NULL ::::::::::::::::::::::::");
                return;
            }

            AgentEvent agentEvent = null;
            CallEvent  callEvent  = null;
            ErrorEvent errorEvent = null;

            if (evt is AgentEvent)
            {
                agentEvent = (AgentEvent)evt;
                raiseAgentEvent(agentEvent);
            }
            else if (evt is CallEvent)
            {
                callEvent = (CallEvent)evt;
                raiseCallEvent(callEvent);
            }
            else if (evt is ErrorEvent)
            {
                errorEvent = (ErrorEvent)evt;
                raiseErrorEvent(errorEvent);
            }
        }
Exemplo n.º 8
0
        private void writeCallEventLog(string eventName, CallEvent evt)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("STATE : ");
            foreach (DictionaryEntry item in evt.getCallStateTable())
            {
                sb.Append("[" + item.Key + " -> " + item.Value + "]");
            }

            StringBuilder actionBuilder = new StringBuilder();

            actionBuilder.Append("ACTION : ");
            foreach (string str in evt.getActionList())
            {
                actionBuilder.Append("[" + str + "]");
            }
            logwrite.write("raiseEvent", ":::::::::::::::::::::::::::::::::::: " + eventName + " ::::::::::::::::::::::::::::::::::::");
            logwrite.write("raiseEvent", evt.getEvtMsg());
            logwrite.write("raiseEvent", "ID : " + evt.getDialogID());
            logwrite.write("raiseEvent", "CALLTYPE : " + evt.getCallType());
            logwrite.write("raiseEvent", "FromAddress : " + evt.getFromAddress());
            logwrite.write("raiseEvent", "ToAddress : " + evt.getToAddress());
            logwrite.write("raiseEvent", sb.ToString());
            logwrite.write("raiseEvent", actionBuilder.ToString());
            logwrite.write("raiseEvent", "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
        }
Exemplo n.º 9
0
        public void Call(string callNumber)
        {
            // непосредственно звонок
            Console.WriteLine("Вызов " + callNumber);
            Console.ReadKey();

            // вызов события по звонку
            CallEvent?.Invoke(this, new CallEventsArgs(IMEI, callNumber));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 映射值
        /// </summary>
        /// <param name="Param"></param>
        public void ExecuteCallData(object Param)
        {
            JObject Obj      = (Param as string).ToModel <JObject>();
            var     CallData = Obj["MiddleResult"].ToJson().ToModel <SocketResultDefault>();

            CallEvent.Instance().Response = new Dictionary <string, object> {
                { "SocketJsonData", CallData.SocketJsonData.ToModel <object>() }
            };
        }
Exemplo n.º 11
0
 private async void TriggerAlertEvent(CallEvent callEvent)
 {
     using (HttpClient _client = new HttpClient())
     {
         Console.WriteLine("Posting to mqtt..");
         var jsonObject = JsonConvert.SerializeObject(new{ alert = "callsCongestionLimitPassed" });
         var content    = new StringContent(jsonObject, Encoding.UTF8, "application/json");
         await _client.PostAsync("http://172.17.0.1:34567/publish", content);
     }
 }
Exemplo n.º 12
0
        private CallEvent InsertNewEvent(CallEvent callEvent)
        {
            CallEvent callEventSerialized = new CallEvent(callEvent);

            callEventSerialized.BsonHourCongestion     = createBsonDocument(callEvent.HourCongestion);
            callEventSerialized.BsonMostCongestedHour  = createBsonDocument(callEvent.MostCongestedHour);
            callEventSerialized.BsonLeastCongestedHour = createBsonDocument(callEvent.LeastCongestedHour);

            _callStatsCollection.InsertOne(callEventSerialized);
            return(callEventSerialized);
        }
Exemplo n.º 13
0
 private async void SendCallsTelemetry(CallEvent callEventSerialized)
 {
     using (HttpClient _client = new HttpClient())
     {
         Console.WriteLine("Posting telemetry to mqtt..");
         var jsonObject = JsonConvert.SerializeObject(new
                                                      { callsTelemetry = callEventSerialized.BsonHourCongestion });
         var content = new StringContent(jsonObject, Encoding.UTF8, "application/json");
         await _client.PostAsync("http://172.17.0.1:34567/publish", content);
     }
 }
Exemplo n.º 14
0
 public void CallingTo(PhoneNumber targetNumber)
 {
     if (targetNumber != phoneNumber)
     {
         CallEvent?.Invoke(this, new EventArgsCall(phoneNumber, targetNumber));
     }
     else
     {
         interaction.CallingToYourselfMessage(targetNumber);
     }
 }
Exemplo n.º 15
0
        public void OutgoingCall(int outgoingNumber)
        {
            ICallInfo callInfo = new CallInfo()
            {
                ClientNumberOfTelephone = ClientNumberOfTelephone, OutgoingNumber = outgoingNumber
            };

            MessageHandlerEvent(this, $"Попытка вызова абонентом  {callInfo.ClientNumberOfTelephone} абонента {callInfo.OutgoingNumber}");
            CallEvent?.Invoke(this, callInfo);
            CurrentCallInfo = callInfo;
        }
Exemplo n.º 16
0
        /// <summary>
        /// 重新连接通信中心
        /// </summary>
        /// <param name="Action"></param>
        public static void ReOpenInternalSocket(Action <ProxyBasic> Action)
        {
            ProxyBasic Client = new ProxyBasic();

            Action(Client);
            if (Call.SocketClient.IsConnected)
            {
                Call.SocketClient.DisConnect();
            }
            CallEvent.Instance().Changed += new CallEvent.ResultEventHandler(CallEventAction.Instance().OnResponse);
            Client.InitInternalSocket(Client.SockInfoIP, Client.SockInfoPort, DependencyExecute.Instance.FindLibrary());
        }
Exemplo n.º 17
0
 public void OutgoingCall(string targetPhoneNumber)
 {
     if (isConnectedToPort)
     {
         Console.WriteLine($"Terminal {PhoneNumber} calling to {targetPhoneNumber}");
         CallEvent?.Invoke(this, new CallEventArgs(PhoneNumber, targetPhoneNumber));
     }
     else
     {
         throw new ArgumentException("Your terminal didn't connect to terminal");
     }
 }
Exemplo n.º 18
0
        /// <summary>
        /// 初始化通信中心Socket
        /// </summary>
        /// <param name="Action"></param>
        /// <param name="UseServer"></param>
        public static void InitInternalSocket(Action <ProxyBasic> Action, bool UseServer = false)
        {
            ProxyBasic Client = new ProxyBasic();

            Action(Client);
            SocketConstConfig.ClientPort = Client.ClientPort;
            if (UseServer)
            {
                CallEvent.Instance().Changed += new CallEvent.ResultEventHandler(CallEventAction.Instance().OnResponse);
                Client.InitInternalSocket(Client.SockInfoIP, Client.SockInfoPort, DependencyExecute.Instance.FindLibrary());
            }
        }
Exemplo n.º 19
0
        private void RegDroppedCall(CallEventArgs arg)
        {
            var call = calls.FirstOrDefault(x => x.Source == arg.SourceNumber && x.Target == arg.TargetNumber);

            if (call == null)
            {
                return;
            }
            calls.Remove(call);

            call.Duration = DateTime.Now - call.CallDate;
            CallEvent?.Invoke(this, call);
        }
Exemplo n.º 20
0
        async public Task <List <CallEvent> > GetEventsAsync()
        {
            var callStats = await _callStatsCollection.Find(x => true).ToListAsync();

            var callStatsDeserialized = callStats.Select(x =>
            {
                CallEvent callEventCopy          = new CallEvent(x);
                callEventCopy.LeastCongestedHour = DeserializeBsonDoc(callEventCopy.BsonLeastCongestedHour);
                callEventCopy.MostCongestedHour  = DeserializeBsonDoc(callEventCopy.BsonMostCongestedHour);
                callEventCopy.HourCongestion     = DeserializeBsonDoc(callEventCopy.BsonHourCongestion);
                return(callEventCopy);
            });

            return(callStatsDeserialized.ToList());
        }
Exemplo n.º 21
0
        public void OpenNewThreadWithRun(CallEvent callBack, object param)
        {
            AsyncCallback call = new AsyncCallback(t =>
            {
                callBack(param);
            });

            if (th == null)
            {
                th = new AsyncRequestThreadHelper(call);
            }
            new Thread(() =>
            {
                th.SetComplate();
            }).Start();
        }
Exemplo n.º 22
0
        public async void UpdateStats()
        {
            var response              = _callConsumer.fetchData();
            var responseContent       = await response;
            var responseContentString = await responseContent.ReadAsStringAsync();

            List <Call> _collectedCalls = JsonConvert.DeserializeObject <List <Call> >(responseContentString);

            List <CallDuration> _collectedCallStats = ConvertCallsToStats(_collectedCalls);
            double yIntercept, slope;

            AnalyzeCallDuration(_collectedCallStats, out yIntercept, out slope);
            Dictionary <int, int> hourlyCongestion = createPredictedHourlyCongestion(yIntercept, slope);
            CallEvent             callEvent        = createEvent(hourlyCongestion);
            CallEvent             insertedEvent    = InsertNewEvent(callEvent);

            TriggerAlertEvent(callEvent);
            SendCallsTelemetry(insertedEvent);
        }
Exemplo n.º 23
0
        public void TestCreateEventActionHandover()
        {
            int blocked         = 0;
            int started         = 0;
            int created         = 0;
            int createdhandover = 0;
            int createdend      = 0;

            var data    = new CallData(1, 5, 20, 0);
            var station = new Station(2, 0, 0, 10);

            var e = new CallEvent(
                station,
                data,
                () => { blocked++; },
                () => { started++; },
                (d) =>
            {
                created++;
                Assert.AreEqual((uint)0, d);
            },
                (d, cd) =>
            {
                createdend++;
                Assert.AreEqual(data, cd);
            },
                (d, cd) =>
            {
                createdhandover++;
                Assert.AreEqual(data, cd);
                Assert.AreEqual((uint)5, d);
            },
                0);

            e.Action();

            Assert.AreEqual(0, blocked);
            Assert.AreEqual(1, created);
            Assert.AreEqual(1, started);
            Assert.AreEqual(0, createdend);
            Assert.AreEqual(1, createdhandover);
        }
Exemplo n.º 24
0
    private void ParseStringToVK()
    {
        try
        {
            string   queryStr = instance.commandField.text;
            string[] tmpArray = queryStr.Split('?');
            string   method   = tmpArray[0];
            Dictionary <string, string> parameters = null;

            //find array after ?
            if (tmpArray.Length > 1 && tmpArray[1].Length > 0)
            {
                //find array after &
                tmpArray = tmpArray[1].Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
                if (tmpArray[0].Contains('='))
                {
                    parameters = tmpArray.ToDictionary(x => x.Split('=')[0], x => x.Split('=')[1]);
                }
                else
                {
                    string action = tmpArray[0];

                    if (instance.clientAPIToggle.isOn)
                    {
                        CallClientAPIEvent.Invoke(method, action, null);
                    }
                }
            }

            if (instance.clientAPIToggle.isOn)
            {
                CallClientAPIEvent.Invoke(method, null, parameters);
            }
            else
            {
                CallEvent.Invoke(method, parameters);
            }
        }
        catch (Exception e) {
            Debug.LogError(e);
        }
    }
Exemplo n.º 25
0
        private CallEvent createEvent(Dictionary <int, int> hourlyCongestion)
        {
            CallEvent callEvent = new CallEvent();

            callEvent.HourCongestion = hourlyCongestion;

            var maxHourDuration = hourlyCongestion.Values.Max();
            var keyOfMax        = hourlyCongestion.Aggregate((x, y) => x.Value > y.Value ? x : y).Key;

            callEvent.MostCongestedHour.Add(keyOfMax, maxHourDuration);

            var minHourDuration = hourlyCongestion.Values.Min();
            var keyOfMin        = hourlyCongestion.Aggregate((x, y) => x.Value < y.Value ? x : y).Key;

            callEvent.LeastCongestedHour.Add(keyOfMin, minHourDuration);

            callEvent.LastUpdatedAt = BsonDateTime.Create(DateTime.Now);

            return(callEvent);
        }
Exemplo n.º 26
0
 private void setActiveDialogID(CallEvent evt)
 {
     if (evt.getCallType().Equals("CONSULT") || evt.getCallType().Equals(CALL.PLAY_AGENT_GREETING))
     {
         dialogID_second = evt.getDialogID();
         activeDialogID  = dialogID_second;
     }
     else
     {
         if (evt.getDialogID().Equals(dialogID_second))
         {
             dialogID_second = evt.getDialogID();
             activeDialogID  = dialogID_second;
         }
         else
         {
             dialogID       = evt.getDialogID();
             activeDialogID = dialogID;
         }
     }
     logwrite.write("setDialogID", "Active DialogID : " + activeDialogID + " , first ID : " + dialogID + " , seconde ID : " + dialogID_second);
     logwrite.write("", "");
 }
Exemplo n.º 27
0
        private void removeDialogID(CallEvent evt)
        {
            if (dialogID_second.Equals(evt.getDialogID()))
            {
                dialogID_second = "";
                activeDialogID  = dialogID;
            }
            if (dialogID.Equals(evt.getDialogID()))
            {
                dialogID       = "";
                activeDialogID = "";
            }

            logwrite.write("removeDialogID", "Active DialogID : " + activeDialogID + " , first ID : " + dialogID + " , seconde ID : " + dialogID_second);

            if (activeDialogID.Length == 0 && dialogID.Length == 0 && dialogID_second.Length == 0)
            {
                logwrite.write("removeDialogID", "### THERE IS NO ANY ACTIVE CALL. CLEARE CALL DATA !! ##");
                if (callDataTable != null)
                {
                    callDataTable.Clear();
                }
            }
        }
Exemplo n.º 28
0
 public void MakeCall(PhoneNumber phoneNumber)
 {
     CallEvent?.Invoke(this, phoneNumber);
 }
Exemplo n.º 29
0
        public void addCallEvent(XElement callNode, Package pkg)
        {
            // Bouml preserved body begin 0001F5E7

            string type = "", className = "", id = "";

            XAttribute attr = (XAttribute)callNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}type");
            if (attr == null) attr = (XAttribute)callNode.Attribute("{http://www.omg.org/spec/XMI/20131001}type");

            if (attr != null) type = attr.Value;

            attr = (XAttribute)callNode.Attribute("name");
            if (attr != null) className = attr.Value;

            if (type.CompareTo("uml:CallEvent") != 0)
            {
                //Debug.Log(className + " is a " + type + " and must be a signal");
                return;
            }

            attr = (XAttribute)callNode.Attribute("id");
            if (attr != null) id = attr.Value;

            CallEvent callEvent = new CallEvent(id);
            attr = (XAttribute)callNode.Attribute("operation");

            if (attr != null) _callEvents.Add(callEvent, attr.Value);

            _events.Add(id, callEvent);
            // Bouml preserved body end 0001F5E7
        }
        public void HandleHandHistory(string handHistory)
        {
            _summary = false;
            ResetOpponentsEvent?.Invoke();

            foreach (var line in handHistory.Split('\n'))
            {
                if (line.Contains("Seat") && !line.Contains("button") && !_summary)
                {
                    var split = line.Split(':');
                    var name  = split[1].Substring(1, split[1].IndexOf('(') - 2);
                    if (name == Controller.User.UserName)
                    {
                        continue;
                    }

                    if (!Controller.Opponents.ContainsKey(name))
                    {
                        Controller.Opponents[name] = new Opponent {
                            Name = name, HandsPlayed = 1
                        }
                    }
                    ;
                    else
                    {
                        Controller.Opponents[name].HandsPlayed++;
                        Controller.Opponents[name].InPlay = true;
                    }
                }
                else if (line.Contains("HOLE") || line.Contains("FLOP") || line.Contains("TURN") ||
                         line.Contains("RIVER") || line.Contains("SHOW DOWN") || line.Contains("SUMMARY"))
                {
                    var split = line.Split(' ');
                    SetHandHistoryStateEvent?.Invoke(split[1]);

                    if (line.Contains("SUMMARY"))
                    {
                        _summary = true;
                    }
                }
                else if (line.Contains(Controller.User.UserName) && line.Contains("collected"))
                {
                    SetHandWonEvent?.Invoke();
                }
                else if (line.Contains(Controller.User.UserName))
                {
                    if (line.Contains("calls"))
                    {
                        CallEvent?.Invoke();
                    }
                    else if (line.Contains("bets"))
                    {
                        BetEvent?.Invoke();
                    }
                    else if (line.Contains("raises"))
                    {
                        RaiseEvent?.Invoke();
                    }
                    else if (line.Contains("checks"))
                    {
                        CheckEvent?.Invoke();
                    }
                    else if (line.Contains("folds"))
                    {
                        FoldEvent?.Invoke();
                    }
                }
                else if (line.Contains("Hand #"))
                {
                    var split = line.Split(' ');
                    SetHandNumEvent?.Invoke(split[2]);
                }
                else if (line.Contains("calls"))
                {
                    var user = line.Split(':')[0];
                    OpponentCallEvent?.Invoke(user);
                }
                else if (line.Contains("checks"))
                {
                    var user = line.Split(':')[0];
                    OpponentCheckEvent?.Invoke(user);
                }
                else if (line.Contains("bets"))
                {
                    var user = line.Split(':')[0];
                    OpponentBetEvent?.Invoke(user);
                }
                else if (line.Contains("raises"))
                {
                    var user = line.Split(':')[0];
                    OpponentRaiseEvent?.Invoke(user);
                }
                else if (line.Contains("folds"))
                {
                    var user = line.Split(':')[0];
                    OpponentFoldEvent?.Invoke(user);
                }
            }
        }
Exemplo n.º 31
0
 public void Call(int callNumber)
 {
     CallEvent?.Invoke(this, new CallArgs(TerminalNumber, callNumber));
 }