public void TestConnect()
        {
            var expectedJson  = @"[{""endpoint"":[{""number"":""447700900001"",""dtmfAnswer"":""2p02p"",""onAnswer"":{""url"":""https://example.com/answer"",""ringbackTone"":""http://example.com/ringbackTone.wav""},""type"":""phone""}],""from"":""447700900000"",""eventType"":""synchronous"",""timeout"":""60"",""limit"":""7200"",""machineDetection"":""continue"",""eventUrl"":[""https://exampe.com/webhooks/events""],""eventMethod"":""POST"",""ringbackTone"":""http://example.com/ringbackTone.wav"",""action"":""connect""}]";
            var connectAction = new ConnectAction
            {
                Endpoint = new[]
                {
                    new PhoneEndpoint
                    {
                        Number     = "447700900001",
                        DtmfAnswer = "2p02p",
                        OnAnswer   = new PhoneEndpoint.Answer
                        {
                            Url          = "https://example.com/answer",
                            RingbackTone = "http://example.com/ringbackTone.wav"
                        }
                    }
                },
                From             = "447700900000",
                EventType        = "synchronous",
                Timeout          = "60",
                Limit            = "7200",
                MachineDetection = "continue",
                EventUrl         = new[] { "https://exampe.com/webhooks/events" },
                RingbackTone     = "http://example.com/ringbackTone.wav",
                EventMethod      = "POST"
            };
            var ncco = new Ncco(connectAction);

            Assert.Equal(expectedJson, ncco.ToString());
        }
Example #2
0
        public IActionResult Answer()
        {
            var TO_NUMBER     = Environment.GetEnvironmentVariable("TO_NUMBER") ?? "TO_NUMBER";
            var VONAGE_NUMBER = Environment.GetEnvironmentVariable("VONAGE_NUMBER") ?? "VONAGE_NUMBER";
            var host          = Request.Host.ToString();
            //Uncomment the next line if using ngrok with --host-header option
            //host = Request.Headers["X-Original-Host"];

            var eventUrl   = $"{Request.Scheme}://{host}/SplitAudio/webhooks/recording";
            var talkAction = new TalkAction {
                Text = "recording call", BargeIn = "false"
            };
            var recordAction = new RecordAction()
            {
                EventUrl    = new string[] { eventUrl },
                EventMethod = "POST",
                Channels    = 2,
                Split       = "conversation"
            };

            var connectAction = new ConnectAction()
            {
                From     = VONAGE_NUMBER,
                Endpoint = new[] { new PhoneEndpoint {
                                       Number = TO_NUMBER
                                   } },
            };

            var ncco = new Ncco(talkAction, recordAction, connectAction);

            return(Ok(ncco.ToString()));
        }
Example #3
0
    public void CreateRoom()
    {
        roomID        = GenerateID.NumberOnly(5);
        connectAction = ConnectAction.CREATE;

        Connect();
    }
Example #4
0
    public void FindRandomRoom()
    {
        roomID        = string.Empty;
        connectAction = ConnectAction.RANDOM;

        Connect();
    }
Example #5
0
        private Response OnAnswerRecordingSplitAudio()
        {
            string TO_NUMBER    = "TO_NUMBER";
            string NEXMO_NUMBER = "NEXMO_NUMBER";

            var recordAction = new RecordAction()
            {
                Split    = "conversation",
                Channels = 2,
                EventUrl = new [] { $"{SiteBase}/webhook/record" }
            };
            var phoneEndpoint = new PhoneEndpoint()
            {
                Number = TO_NUMBER
            };
            var connectAction = new ConnectAction()
            {
                From     = NEXMO_NUMBER,
                Endpoint = new [] { phoneEndpoint }
            };

            var ncco = new Ncco(recordAction, connectAction);

            return(ncco.ToString());
        }
        public IActionResult Answer()
        {
            var TO_NUMBER     = Environment.GetEnvironmentVariable("TO_NUMBER") ?? "TO_NUMBER";
            var VONAGE_NUMBER = Environment.GetEnvironmentVariable("VONAGE_NUMBER") ?? "VONAGE_NUMBER";
            var host          = Request.Host.ToString();
            //Uncomment the next line if using ngrok with --host-header option
            //host = Request.Headers["X-Original-Host"];
            var sitebase = $"{Request.Scheme}://{host}";

            var recordAction = new RecordAction()
            {
                EventUrl    = new string[] { $"{sitebase}/recordcall/webhooks/recording" },
                EventMethod = "POST"
            };

            var connectAction = new ConnectAction()
            {
                From = VONAGE_NUMBER, Endpoint = new[] { new PhoneEndpoint {
                                                             Number = TO_NUMBER
                                                         } }
            };

            var ncco = new Ncco(recordAction, connectAction);

            return(Ok(ncco.ToString()));
        }
Example #7
0
 public static CurrentUserState OnConnect(CurrentUserState state, ConnectAction action)
 {
     return(state with
     {
         CircuitId = action.CircuitId
     });
 }
Example #8
0
 private void WhenConnect(IPeer peer, ConnectAction action)
 {
     if (peer.IsConnectedTo(action.Model))
     {
         return;
     }
     peer.AddRelation(_network.FindAgent(action.Model));
 }
Example #9
0
        public void Connect(IPAddress ipAddress, int port)
        {
            ConnectCalledTimes++;
            if (ConnectAction != null)
            {
                ConnectAction.Invoke(ipAddress, port);
                return;
            }

            Connected      = true;
            RemoteEndPoint = new IPEndPoint(ipAddress, port);
            ConnectCalled?.Invoke(ipAddress, port);
        }
Example #10
0
    public void FindRoom(string _roomID)
    {
        if (_roomID == string.Empty || _roomID.Length < 5)
        {
            print("O ID " + _roomID + " é invalido");
            FindObjectOfType <MenuManager>().LoadScreen(false);
        }
        else
        {
            roomID        = _roomID;
            connectAction = ConnectAction.FIND;

            Connect();
        }
    }
Example #11
0
        private Response OnAnswerConnect()
        {
            var talkAction = new TalkAction()
            {
                Text      = "Thank you for calling",
                VoiceName = "Kimberly"
            };
            var phoneEndpoint = new PhoneEndpoint()
            {
                Number = "TO_NUMBER"
            };
            var connectAction = new ConnectAction()
            {
                From     = Request.Query.from.Value,
                Endpoint = new[] { phoneEndpoint }
            };

            var ncco = new Ncco(talkAction, connectAction);

            return(ncco.ToString());
        }
Example #12
0
        public async Task Handle(ConnectAction action, IDispatcher dispatcher)
        {
            var connection = new HubConnectionBuilder()
                             .WithUrl(NavigationManager.ToAbsoluteUri($"/gamehub"))
                             .WithAutomaticReconnect()
                             .Build();

            //var server = new GameServerProxy(connection);
            var server = connection.AsGeneratedHub <IGameServer>();

            var gameClient = ServiceProvider.GetService(typeof(IGameClient));

            connection.RegisterSpoke <IGameClient>(gameClient);

            connection.Closed       += (Exception ex) => Task.Run(() => dispatcher.Dispatch(new DisconnectedEvent()));
            connection.Reconnected  += (string id) => Task.Run(() => dispatcher.Dispatch(new ReconnectedEvent()));
            connection.Reconnecting += (Exception ex) => Task.Run(() => dispatcher.Dispatch(new ReconnectingEvent()));

            await connection.StartAsync();

            dispatcher.Dispatch(new ConnectedEvent(connection, server));
        }
        public string Answer()
        {
            Ncco ncco;

            if (Request.Query.ContainsKey("to") && Request.Query["to"] == "12012971365")
            {
                var talkAction = new TalkAction {
                    Text = "Please wait while you're connected to the call"
                };
                var connectAction = new ConnectAction
                {
                    Timeout  = "20",
                    From     = "12012854946",
                    Endpoint = new[] { new Nexmo.Api.Voice.Nccos.Endpoints.AppEndpoint
                                       {
                                           User = "******"
                                       } }
                };
                ncco = new Ncco(talkAction, connectAction);
            }
            else
            {
                var talkAction = new TalkAction {
                    Text = "Please wait while you're connected to the call"
                };
                var connectAction = new ConnectAction
                {
                    Timeout  = "20",
                    From     = "12012854946",
                    Endpoint = new[] { new Nexmo.Api.Voice.Nccos.Endpoints.PhoneEndpoint
                                       {
                                           Number = "12018747427"
                                       } }
                };
                ncco = new Ncco(talkAction, connectAction);
            }

            return(ncco.ToString());
        }
        public string Answer()
        {
            var webSocketAction = new ConnectAction()
            {
                Endpoint = new[]
                {
                    new WebsocketEndpoint()
                    {
                        Uri         = $"wss://{BASE_URL}/ws",
                        ContentType = "audio/l16;rate=8000",
                        Headers     = new Dictionary <string, string>()
                        {
                            { "language", LANGUAGE }
                        }
                    }
                }
            };

            var ncco = new Ncco(webSocketAction);

            return(ncco.ToString());
        }
        public string Answer()
        {
            var YOUR_SECOND_NUMBER = Environment.GetEnvironmentVariable("YOUR_SECOND_NUMBER") ?? "YOUR_SECOND_NUMBER";
            var VONAGE_NUMBER      = Environment.GetEnvironmentVariable("VONAGE_NUMBER") ?? "VONAGE_NUMBER";

            var talkAction = new TalkAction()
            {
                Text      = "Thank you for calling",
                VoiceName = "Kimberly"
            };

            var secondNumberEndpoint = new PhoneEndpoint()
            {
                Number = YOUR_SECOND_NUMBER
            };
            var connectAction = new ConnectAction()
            {
                From = VONAGE_NUMBER, Endpoint = new[] { secondNumberEndpoint }
            };

            var ncco = new Ncco(talkAction, connectAction);

            return(ncco.ToString());
        }
        public ActionResult Answer()
        {
            var host            = Request.Host.ToString();
            var webSocketAction = new ConnectAction()
            {
                Endpoint = new[]
                {
                    new WebsocketEndpoint()
                    {
                        Uri         = $"ws://{host}/ws",
                        ContentType = "audio/l16;rate=16000",
                        Headers     = new Translation
                        {
                            UUID               = Request.Query["uuid"].ToString(),
                            LanguageSpoken     = "en-US",
                            LanguageTranslated = "es-MX"
                        }
                    }
                }
            };
            var ncco = new Ncco(webSocketAction);

            return(Ok(ncco.ToString()));
        }