Пример #1
0
        private void ShutdownUserEndpoint(AsyncTask task, object state)
        {
            UserEndpoint userEndpoint = state as UserEndpoint;

            if (userEndpoint == null)
            {
                task.Complete(null);
                return;
            }
            task.DoOneStep(
                delegate()
            {
                Logger.Log(Logger.LogLevel.Info, "Terminating UserEndpoint." + userEndpoint.OwnerUri);
                userEndpoint.BeginTerminate(
                    delegate(IAsyncResult ar)
                {
                    task.DoFinalStep(
                        delegate()
                    {
                        userEndpoint.EndTerminate(ar);
                        Logger.Log(Logger.LogLevel.Info, "Terminated UserEndpoint." + userEndpoint.OwnerUri);
                    });
                },
                    null);
            });
        }
Пример #2
0
            public void Stop()
            {
                currentOperation.Stop(
                    () =>
                {
                    // Wait for rooms to stop doing work
                    List <WaitHandle> waitHandles = new List <WaitHandle>();
                    foreach (SimulatedChatRoom room in chatRoomSessions)
                    {
                        waitHandles.Add(room.WaitForStopped);
                        room.Stop();
                    }
                    if (waitHandles.Count > 0)
                    {
                        WaitHandle.WaitAll(waitHandles.ToArray());
                    }
                },
                    () =>
                {
                    // Teardown
                    chatRoomSessions.Clear();
                    chatRooms.Clear();

                    if (persistentChatEndpoint != null)
                    {
                        SampleCommon.DisconnectPersistentChatServer(persistentChatEndpoint);
                        persistentChatEndpoint = null;
                    }
                    if (userEndpoint != null)
                    {
                        SampleCommon.DisconnectOfficeCommunicationServer(userEndpoint);
                        userEndpoint = null;
                    }
                });
            }
Пример #3
0
        public ActionResult SignUp(SignUpViewModel model)
        {
            if (model.Password != model.ConfirmPassword)
            {
                ModelState.AddModelError("ConfirmPassword", "Passwords don't match");
                return(View(model));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    UserEndpoint ue = new UserEndpoint();
                    ue.Register(model.UserName);
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { PrivateKey = string.Empty, PublicKey = string.Empty });
                    TempData["Notification"] = new Notification("Please check your e-mail, we sent you access keys.", Nature.success);

                    return(RedirectToAction("Login"));
                }
                catch (Exception ex)
                {
                    return(View("Error"));
                }
            }
            else
            {
                return(View(model));
            }
        }
Пример #4
0
        private void EndEndpointEstablish(IAsyncResult ar)
        {
            UserEndpoint userEndpoint = ar.AsyncState as UserEndpoint;

            try
            {
                userEndpoint.EndEstablish(ar);
                Console.WriteLine("The User Endpoint owned by URI: ");
                Console.WriteLine(userEndpoint.OwnerUri);
                Console.WriteLine(" is now established and registered.");
            }
            catch (ConnectionFailureException connFailEx)
            {
                // ConnectionFailureException will be thrown when the endpoint cannot connect to the server, or the credentials are invalid.
                // It is left to the developer to write real error handling code.
                Console.WriteLine(connFailEx.ToString());
            }
            catch (InvalidOperationException iOpEx)
            {
                // InvalidOperationException will be thrown when the endpoint is not in a valid state to connect. To connect, the platform must be started and the Endpoint Idle.
                // It is left to the developer to write real error handling code.
                Console.WriteLine(iOpEx.ToString());
            }
            catch (RegisterException regEx)
            {
                // RegisterException will be thrown when the endpoint cannot be registered (usually due to bad credentials).
                // It is left to the developer to write real error handling code (here, the appropriate action is likely reprompting for user/password/domain strings).
                Console.WriteLine(regEx.ToString());
            }

            //Again, just for sync. reasons.
            _autoResetEvent.Set();
        }
Пример #5
0
        private void Run()
        {
            // A helper class to take care of platform and endpoint setup and
            // cleanup. This has been abstracted from this sample to focus on
            // Call Control.
            _helper = new UCMASampleHelper();

            // Create a user endpoint, using the network credential object
            // defined above.
            _userEndpoint = _helper.CreateEstablishedUserEndpoint("DeclineCall Sample User" /*endpointFriendlyName*/);


            // Here, we are Declining an Instant Messaging call only. If the
            // incoming call is not an Instant Messaging call (for example, an
            // AudioVideo call, or a custom (Foo) Call, then it will not get
            // raised to the application. UCMA 3.0 handles this silently by
            // having the call types register for various modalities (as part of
            // the extensibility framework). The appropriate action (here,
            // declining the call) will be handled in the handler assigned to the
            // method call below.
            _userEndpoint.RegisterForIncomingCall <InstantMessagingCall>(On_InstantMessagingCall_Received);

            // Wait for the call to complete Decline, then shutdown the platform.
            Console.WriteLine("Waiting for incoming call...");
            _autoResetEvent.WaitOne();

            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shutdown and exit.");

            // Shut down the sample.
            _helper.ShutdownPlatform();
        }
        //Launches an instant message. Text of the message depends on the parameter value.
        public void UcmaIM(Int32 choice)
        {
            helper       = new UCMASampleHelper();
            userEndpoint = helper.CreateEstablishedUserEndpoint("SampleUser");
            Console.WriteLine("endpoint owned by " + userEndpoint.OwnerUri + " is established/registered");

            ConversationSettings conversationSettings = new ConversationSettings();

            conversationSettings.Subject = conversationSubject;
            Conversation conversation = new Conversation(userEndpoint, conversationSettings);

            ImCall = new InstantMessagingCall(conversation);
            ImCall.InstantMessagingFlowConfigurationRequested += new EventHandler <InstantMessagingFlowConfigurationRequestedEventArgs>(ImCall_InstantMessagingFlowConfigurationRequested);

            Int32 helloChoice   = 1;
            Int32 goodbyeChoice = 2;

            if (choice == helloChoice)
            {
                messageText = "hello";
            }
            else if (choice == goodbyeChoice)
            {
                messageText = "goodbye";
            }
            else
            {
                messageText = "press 1 or press 2";
            }

            string targetURI = ConfigurationManager.AppSettings["UserURI1"];

            ImCall.BeginEstablish(targetURI, null, CallEstablishCompleted, null);
            completedEvent.WaitOne();
        }
Пример #7
0
        public void Run()
        {
            // Initialize and register the endpoint, using the credentials of the user the application will be acting as.
            _helper       = new UCMASampleHelper();
            _userEndpoint = _helper.CreateEstablishedUserEndpoint("B2BCall Sample User" /*endpointFriendlyName*/);
            _userEndpoint.RegisterForIncomingCall <AudioVideoCall>(inboundAVCall_CallReceived);

            // Conversation settings for the outbound call (to the agent).
            ConversationSettings outConvSettings = new ConversationSettings();

            outConvSettings.Priority = _conversationPriority;
            outConvSettings.Subject  = _outConversationSubject;

            // Create the Conversation instance between UCMA and the agent.
            _outboundConversation = new Conversation(_userEndpoint, outConvSettings);

            // Create the outbound call between UCMA and the agent.
            _outboundAVCall = new AudioVideoCall(_outboundConversation);

            // Register for notification of the StateChanged event on the outbound call.
            _outboundAVCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(outboundAVCall_StateChanged);

            // Prompt for called party - the agent.
            _calledParty = UCMASampleHelper.PromptUser("Enter the URI of the called party, in sip:User@Host form or tel:+1XXXYYYZZZZ form => ", "RemoteUserURI1");

            _outboundCallLeg = new BackToBackCallSettings(_outboundAVCall, _calledParty);

            // Pause the main thread until both calls, the BackToBackCall, both conversations,
            // and the platform are shut down.
            _waitUntilOneUserHangsUp.WaitOne();

            // Pause the console to allow for easier viewing of logs.
            Console.WriteLine("Press any key to end the sample.");
            Console.ReadKey();
        }
Пример #8
0
        /// <summary>
        /// Sets up the OCS objects using the credentials provided
        /// </summary>
        /// <remarks>
        /// In this sample this is invoked when the user presses the "Apply Server Settings" button
        /// </remarks>
        /// <param name="applicationUri">SIP Uri of the OCS account</param>
        /// <param name="serverName">SIP server URI</param>
        /// <param name="serverPort">Port (usually 443)</param>
        /// <param name="credential">Credentials for establishing the user endpoint</param>
        private void InitializeMCSConnection(string applicationUri, string serverName, int serverPort, NetworkCredential credential)
        {
            //Initialize new client platform.
            //Note that this sample only supports TLS, and additionally that it uses ClientPlatform rather than ServerPlatform.
            //In a production application, ServerPlatform should be used; ClientPlatform is preferred here to demonstrate the platform without
            //requiring application provisioning. This is out of the scope of this sample, however.
            ClientPlatformSettings clientPlatformSettings;

            clientPlatformSettings = new ClientPlatformSettings("VoiceXMLTestApp", SipTransportType.Tls);

            collaborationPlatform = new CollaborationPlatform(clientPlatformSettings);
            collaborationPlatform.EndStartup(collaborationPlatform.BeginStartup(null, null));

            //Create a new UserEndpoint based on the information provided through the UI.
            //As with Server/Client platform above, in production, this should be replaced with provisioned ApplicationEndpoint in most circumstances.
            UserEndpointSettings endpointSettings;

            endpointSettings = new UserEndpointSettings(applicationUri, serverName, serverPort);

            endpoint = new UserEndpoint(collaborationPlatform, endpointSettings);

            endpoint.Credential = credential;

            //Bind the event handler to handle incoming calls. Use of the strongly-typed AVCall dictates that calls not matching this type will not be raised.
            endpoint.RegisterForIncomingCall <AudioVideoCall>(AudioVideoCallReceived);

            endpoint.EndEstablish(endpoint.BeginEstablish(null, endpoint));
        }
        public void Run()
        {
            // Create and establish the endpoint, using the credentials of the user the application will be acting as.
            _helper       = new UCMASampleHelper();
            _userEndpoint = _helper.CreateEstablishedUserEndpoint("VoiceXML Sample User" /*endpointFriendlyName*/);
            _userEndpoint.RegisterForIncomingCall <AudioVideoCall>(inboundAVCall_CallReceived);

            // Pause the main thread until a call is received and then accepted.
            _waitForCallReceived.WaitOne();
            _waitForCallAccepted.WaitOne();

            InitializeVoiceXmlBrowser();
            _voiceXmlBrowser.SetAudioVideoCall(_audioVideoCall);
            Uri startPageURI = new Uri(startPageURL);

            Console.WriteLine("Browser state: " + _voiceXmlBrowser.State.ToString());
            _voiceXmlBrowser.RunAsync(startPageURI, null);
            _waitForSessionCompleted.WaitOne();

            _collabPlatform = _conversation.Endpoint.Platform;
            // Terminate the call.
            _audioVideoCall.BeginTerminate(CallTerminateCB, _audioVideoCall);

            _waitForPlatformShutdownCompleted.WaitOne();

            // Pause the console to allow the user to view logs.
            Console.WriteLine("Press any key to end the sample.");
            Console.ReadKey();
        }
Пример #10
0
            public void Start(List <Uri> chatRoomsToJoin)
            {
                Console.WriteLine("正在登陆用户");
                Console.ReadKey();

                try
                {
                    chatRooms = chatRoomsToJoin;

                    // Connect to Lync Server
                    ClientPlatformSettings platformSettings = new ClientPlatformSettings("PersistentChat.Test", SipTransportType.Tls);
                    CollaborationPlatform  collabPlatform   = new CollaborationPlatform(platformSettings);
                    collabPlatform.EndStartup(collabPlatform.BeginStartup(null, null));
                    UserEndpointSettings userEndpointSettings = new UserEndpointSettings(UserUri.AbsoluteUri, SampleCommon.LyncServer);
                    userEndpointSettings.Credential = new NetworkCredential(UserName, Password);
                    userEndpoint = new UserEndpoint(collabPlatform, userEndpointSettings);
                    Console.WriteLine("正在登陆用户----------->");
                    // Login to Lync Server
                    currentOperation.Begin("Connect to Lync Server",
                                           () => userEndpoint.BeginEstablish(ar => LyncServerBeginEstablishFinished(ar), null));
                }
                catch (Exception e) {
                    Console.WriteLine("正在登陆用户");
                }
            }
Пример #11
0
        public void Run()
        {
            // A helper class to take care of platform and endpoint setup and cleanup.
            _helper = new UCMASampleHelper();

            // Create a user endpoint using the network credential object.
            _userEndpoint = _helper.CreateEstablishedUserEndpoint("Broadcast User");

            // Register a delegate to be called when an incoming audio-video call arrives.
            _userEndpoint.RegisterForIncomingCall <AudioVideoCall>(AudioVideoCall_Received);

            // Wait for the incoming call to be accepted.
            Console.WriteLine("Waiting for incoming call...");
            _waitForCallToBeAccepted.WaitOne();

            // Create a speech recognition connector and attach an AudioVideoFlow to it.
            SpeechRecognitionConnector speechRecognitionConnector = new SpeechRecognitionConnector();

            speechRecognitionConnector.AttachFlow(_audioVideoFlow);

            // Start the speech recognition connector.
            SpeechRecognitionStream stream = speechRecognitionConnector.Start();

            // Create a speech recognition engine.
            SpeechRecognitionEngine speechRecognitionEngine = new SpeechRecognitionEngine();

            speechRecognitionEngine.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(SpeechRecognitionEngine_SpeechRecognized);

            //Add a grammar.
            string[] recoString = { "buy", "sell", "Fabrikam", "Contoso", "maximum", "minimum", "one", "ten", "twenty", "send" };
            Choices  choices    = new Choices(recoString);

            speechRecognitionEngine.LoadGrammar(new Grammar(new GrammarBuilder(choices)));

            //Attach to audio stream to the SR engine.
            SpeechAudioFormatInfo speechAudioFormatInfo = new SpeechAudioFormatInfo(8000, AudioBitsPerSample.Sixteen, Microsoft.Speech.AudioFormat.AudioChannel.Mono);

            speechRecognitionEngine.SetInputToAudioStream(stream, speechAudioFormatInfo);
            Console.WriteLine("\r\nGrammar loaded, say send to send IM.");

            //Prepare the SR engine to perform multiple asynchronous recognitions.
            speechRecognitionEngine.RecognizeAsync(RecognizeMode.Multiple);

            //Pause the main thread until recognition completes.
            _waitForConnectorToStop.WaitOne();
            speechRecognitionConnector.Stop();
            Console.WriteLine("connector stopped");

            // Detach the flow from the speech recognition connector, to prevent the flow from being kept in memory.
            speechRecognitionConnector.DetachFlow();

            // Terminate the call, the conversation, and then unregister the
            // endpoint from receiving an incoming call.
            _audioVideoCall.BeginTerminate(CallTerminateCB, _audioVideoCall);
            _waitForConversationToBeTerminated.WaitOne();

            // Shut down the platform.
            _helper.ShutdownPlatform();
        }
Пример #12
0
        public Create()
        {
            Mock <ILoggerService <UserEndpoint> > logger     = new Mock <ILoggerService <UserEndpoint> >();
            Mock <IRepositoryService <User> >     repository = new Mock <IRepositoryService <User> >();
            IUserService service = new UserService(repository.Object);

            endpoint = new UserEndpoint(logger.Object, service);
        }
Пример #13
0
        public CustomerServiceWebAppClient(string url, string user, string password, bool useHttps = false)
        {
            Requester requester = new Requester(url, @user, password);

            requester.AddBasicAuth(@user, password);
            Logins = new LoginEndPoint(requester, "/api/account", useHttps);
            Users  = new UserEndpoint(requester, "/api/account/users", useHttps);
        }
Пример #14
0
 public TranscriptRecorderSessionManager()
 {
     _identity = Constants.NextGuid();
     _activeConversationSessions = new Dictionary <Conversation, TranscriptRecorderSession>();
     _activeConferenceSessions   = new Dictionary <ConferenceSession, TranscriptRecorderSession>();
     _helper       = new UcmaHelper();
     _userEndpoint = _helper.CreateEstablishedUserEndpoint(Constants.ApplicationEndpointName);
 }
 public TranscriptRecorderSessionManager()
 {
     _identity = Constants.NextGuid();
     _activeConversationSessions = new Dictionary<Conversation, TranscriptRecorderSession>();
     _activeConferenceSessions = new Dictionary<ConferenceSession, TranscriptRecorderSession>();
     _helper = new UcmaHelper();
     _userEndpoint = _helper.CreateEstablishedUserEndpoint(Constants.ApplicationEndpointName);
 }
Пример #16
0
        public static void Main(string[] args)
        {
            UserEndpoint m = new UserEndpoint();
            string       s = m.GetList();

            Console.WriteLine(s);

            Console.ReadLine();
        }
Пример #17
0
        public static void Main(string[] args)
        {
            //////////////////////////////////////////////////////////////////////////////////////////////////
            // Note: Assuming that category(ies) have been created and this user is a creator on some of them
            //////////////////////////////////////////////////////////////////////////////////////////////////

            try
            {
                // Connect to OCS
                UserEndpoint userEndpoint = SampleCommon.ConnectOfficeCommunicationServer(SampleCommon.UserSipUri,
                                                                                          SampleCommon.OcsServer,
                                                                                          SampleCommon.UsingSso,
                                                                                          SampleCommon.Username,
                                                                                          SampleCommon.Password);

                // Connect to Persistent Chat Server
                PersistentChatEndpoint persistentChatEndpoint = SampleCommon.ConnectPersistentChatServer(userEndpoint,
                                                                                                         SampleCommon.
                                                                                                         PersistentChatServerUri);

                SetupRooms(persistentChatEndpoint);

                GetRiamoLists(persistentChatEndpoint);

                // Disconnect from both Persistent Chat Server and OCS
                SampleCommon.DisconnectPersistentChatServer(persistentChatEndpoint);
                SampleCommon.DisconnectOfficeCommunicationServer(userEndpoint);
            }
            catch (InvalidOperationException invalidOperationException)
            {
                Console.Out.WriteLine("InvalidOperationException: " + invalidOperationException.Message);
            }
            catch (ArgumentNullException argumentNullException)
            {
                Console.Out.WriteLine("ArgumentNullException: " + argumentNullException.Message);
            }
            catch (ArgumentException argumentException)
            {
                Console.Out.WriteLine("ArgumentException: " + argumentException.Message);
            }
            catch (Microsoft.Rtc.Signaling.AuthenticationException authenticationException)
            {
                Console.Out.WriteLine("AuthenticationException: " + authenticationException.Message);
            }
            catch (Microsoft.Rtc.Signaling.FailureResponseException failureResponseException)
            {
                Console.Out.WriteLine("FailureResponseException: " + failureResponseException.Message);
            }
            catch (UriFormatException uriFormatException)
            {
                Console.Out.WriteLine("UriFormatException: " + uriFormatException.Message);
            }
            catch (Exception exception)
            {
                Console.Out.WriteLine("Exception: " + exception.Message);
            }
        }
Пример #18
0
 protected virtual void ConstructEndpoints()
 {
     this.AuthenticationService = new AuthenticationService(this);
     this.projectsService       = new ProjectsService(this);
     this.ActivityService       = new ActivityService(this);
     this.TaskLogService        = new TaskLogService(this);
     this.Users    = new UserEndpoint(this);
     this.Projects = new ProjectEndpoint(this);
     this.Tasks    = new TaskEndpoint(this);
 }
        public static void DisconnectOfficeCommunicationServer(UserEndpoint userEndpoint)
        {
            Console.WriteLine("Disconnecting from OCS...");

            userEndpoint.EndTerminate(userEndpoint.BeginTerminate(null, null));

            CollaborationPlatform platform = userEndpoint.Platform;

            platform.EndShutdown(platform.BeginShutdown(null, null));

            Console.WriteLine("\tSuccess");
        }
Пример #20
0
        public void Run()
        {
            //Initialize and register the endpoint, using the credentials of the user the application will be acting as.
            _helper       = new UCMASampleHelper();
            _userEndpoint = _helper.CreateEstablishedUserEndpoint("AVCall Sample User" /*endpointFriendlyName*/);

            //Set up the conversation and place the call.
            ConversationSettings convSettings = new ConversationSettings();

            convSettings.Priority = _conversationPriority;
            convSettings.Subject  = _conversationSubject;

            //Conversation represents a collection of modalities in the context of a dialog with one or multiple callees.
            Conversation conversation = new Conversation(_userEndpoint, convSettings);

            _audioVideoCall = new AudioVideoCall(conversation);

            //Call: StateChanged: Only hooked up for logging.
            _audioVideoCall.StateChanged += new EventHandler <CallStateChangedEventArgs>(audioVideoCall_StateChanged);

            //Subscribe for the flow configuration requested event; the flow will be used to send the media.
            //Ultimately, as a part of the callback, the media will be sent/received.
            _audioVideoCall.AudioVideoFlowConfigurationRequested += this.audioVideoCall_FlowConfigurationRequested;

            // Prompt for called party
            _calledParty = UCMASampleHelper.PromptUser("Enter the URI for the user logged onto Microsoft Lync, in the sip:User@Host format or tel:+1XXXYYYZZZZ format => ", "RemoteUserURI");

            //Place the call to the remote party.
            _audioVideoCall.BeginEstablish(_calledParty, null, EndCallEstablish, _audioVideoCall);

            //Sync; wait for the call to complete.
            Console.WriteLine("Calling the remote user...");
            _waitForCallToEstablish.WaitOne();

            // Terminate the call, and then the conversation.
            // Terminating these additional objects individually is made redundant by shutting down the platform right after, but in the multiple call case,
            // this is needed for object hygene. Terminating a Conversation terminates all it's associated calls, and terminating an endpoint will terminate
            // all conversations on that endpoint.
            _audioVideoCall.BeginTerminate(EndTerminateCall, _audioVideoCall);
            Console.WriteLine("Waiting for the call to get terminated...");
            _waitForCallToTerminate.WaitOne();
            _audioVideoCall.Conversation.BeginTerminate(EndTerminateConversation, _audioVideoCall.Conversation);
            Console.WriteLine("Waiting for the conversation to get terminated...");
            _waitForConversationToTerminate.WaitOne();

            //Now, cleanup by shutting down the platform.
            Console.WriteLine("Shutting down the platform...");
            _helper.ShutdownPlatform();

            // Pause the console to allow for easier viewing of logs.
            Console.WriteLine("Please hit any key to end the sample.");
            Console.ReadKey();
        }
Пример #21
0
 public bool EstablishUserEndpoint(UserEndpoint userEndpoint)
 {
     if (_isPlatformStarted == false)
     {
         userEndpoint.Platform.BeginStartup(EndPlatformStartup, userEndpoint.Platform);
         _platformStartupCompleted.WaitOne();
         _isPlatformStarted = true;
     }
     userEndpoint.BeginEstablish(EndEndpointEstablish, userEndpoint);
     _endpointInitCompletedEvent.WaitOne();
     return(true);
 }
Пример #22
0
        public UserEndpoint CreateUserEndpoint(UserEndpointSettings userEndpointSettings)
        {
            if (_collabPlatform == null)
            {
                // Initalize and startup the platform.
                ClientPlatformSettings clientPlatformSettings = new ClientPlatformSettings(_applicationName, _transportType);
                _collabPlatform = new CollaborationPlatform(clientPlatformSettings);
            }

            _userEndpoint = new UserEndpoint(_collabPlatform, userEndpointSettings);
            return(_userEndpoint);
        }
Пример #23
0
        private void Run()
        {
            // A helper class to take care of platform and endpoint setup and
            // cleanup. This has been abstracted from this sample to focus on
            // Call Control.
            _helper = new UCMASampleHelper();

            // Create a user endpoint, using the network credential object
            // defined above.
            UserEndpoint callerEndpoint = _helper.CreateEstablishedUserEndpoint(
                "Caller" /*endpointFriendlyName*/);

            // Create a second user endpoint, using the network credential object
            // defined above.
            UserEndpoint calleeEndpoint = _helper.CreateEstablishedUserEndpoint(
                "Callee" /*endpointFriendlyName*/);

            // Here, we are accepting an Instant Messaging call only. If the
            // incoming call is not an Instant Messaging call (for example, an
            // AudioVideo call or a custom Call, then it will not get raised to
            // the application. UCMA 3.0 handles this silently by having the call
            // types register for various modalities (as part of the extensibility
            // framework). The appropriate action (here, accepting the call) will
            // be handled in the handler assigned to the method call below.
            calleeEndpoint.RegisterForIncomingCall <InstantMessagingCall>(On_InstantMessagingCall_Received);

            // Setup the call and conversation objects for the initial call (IM)
            // and place the call (synchronously).
            _conversation = new Conversation(callerEndpoint);
            InstantMessagingCall instantMessagingCall = new InstantMessagingCall(_conversation);


            // Add registration for the AudioVideo modality, before placing the
            // second call. This could have been done at any time before placing
            // the audio video call. This handler could choose to accept, deflect
            // or drop this portion of the call entirely.
            calleeEndpoint.RegisterForIncomingCall <AudioVideoCall>(On_AudioVideoCall_Received);

            // Place the call to the remote party, without specifying any custom
            // options.
            instantMessagingCall.BeginEstablish(calleeEndpoint.OwnerUri, new ToastMessage("Sample Toast Message"),
                                                null, CallEstablishCompleted, instantMessagingCall);

            // Force synchronization to ensure that the both AVCall and IMCall
            // are now complete.
            _sampleCompleted.WaitOne();

            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shutdown and exit.");

            //And shutdown (synchronously).
            Console.WriteLine("Shutting down the sample...");
            _helper.ShutdownPlatform();
        }
Пример #24
0
        public facebookManager(UserEndpoint user)
        {
            _user = user;
            InitializeComponent();
            _http = new HttpClient()
            {
                BaseAddress = new Uri("https://graph.facebook.com/v7.0/")
            };
            _http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            getUser();
        }
        public static PersistentChatEndpoint ConnectPersistentChatServer(UserEndpoint userEndpoint, Uri persistentChatServerUri)
        {
            Console.WriteLine("{0} Connecting to Persistent Chat Server...", userEndpoint.EndpointUri);

            PersistentChatEndpoint persistentChatEndpoint = new PersistentChatEndpoint(persistentChatServerUri, userEndpoint);

            persistentChatEndpoint.EndEstablish(persistentChatEndpoint.BeginEstablish(null, null));
            Console.WriteLine("\t{0}-ConnectPersistentChatServer >>>>Successing" + userEndpoint.EndpointUri);

            DisplayServerInfo(persistentChatEndpoint.PersistentChatServices.ServerConfiguration);

            return(persistentChatEndpoint);
        }
Пример #26
0
        // Method to create an endpoint given a UserEndpointSettings object.
        // This method returns a UserEndpoint object so that you can wire up Endpoint-specific event handlers.
        // If you do not want to get endpoint specific event information at the time the endpoint is established, you may
        // want to call the CreateEstablishedUserEndpoint method directly. Otherwise, you may call ReadUserSettings
        // followed by CreateUserEndpoint, followed by EstablishUserEndpoint methods.
        public UserEndpoint CreateUserEndpoint(UserEndpointSettings userEndpointSettings)
        {
            // Reuse platform instance so that all endpoints share the same platform.
            if (_collabPlatform == null)
            {
                // Initialize and start the platform.
                ClientPlatformSettings clientPlatformSettings = new ClientPlatformSettings(_applicationName, _transportType);
                _collabPlatform = new CollaborationPlatform(clientPlatformSettings);
            }

            _userEndpoint = new UserEndpoint(_collabPlatform, userEndpointSettings);
            return(_userEndpoint);
        }
        public static Task EstablishAsync(this
                                          UserEndpoint endpoint)
        {
            Action <IAsyncResult> action = (result) =>
            {
                endpoint.EndEstablish(result);
            };

            return(Task.Factory.FromAsync(
                       endpoint.BeginEstablish,
                       action,
                       null));
        }
Пример #28
0
        public void CreateUserEndpoint(string userURI)
        {
            UserEndpointSettings settings = new UserEndpointSettings(userURI);

            user = new UserEndpoint(collabPlatform, settings);
            user.EndEstablish(user.BeginEstablish(null, null));
            if (user.State != LocalEndpointState.Established)
            {
                throw new Exception("Local endpoint state is not established");
            }

            alertNotification = null;
        }
Пример #29
0
        static void Main(string[] args)
        {
            // user end-point
            var user = new UserEndpoint(username: "", password: "");

            user.Post("Send from Facebook SDK");                        // post to logged users wall
            // Missing some stuff as like, comment, block another user, etc
            user.GetUserInfo("beciuu94", new Models.User.UserInfoOption // gather another user information
            {
                FbInfoOption = new Models.User.FacebookInfoOption
                {
                    IncludeAvatarUrl       = true,
                    IncludeFbFriends       = true,
                    IncludeFbUrl           = true,
                    IncludeUserDisplayName = true,
                    IncludeUserId          = true
                },
                IncludeAddressInfo      = true,
                IncludeBasicInfo        = true,
                IncludeContactInfo      = false,
                IncludeEduInfo          = false,
                IncludeRelationshipInfo = false,
                IncludeWorkInfo         = false
            });

            // Page end-point
            var page = new PageEndpoint(username: "", password: "");

            page.GetPageId(pageAlias: "FHNChallengingTheImpossible");             // get id from page alias
            page.GetPageAlbums(pageAlias: "FHNChallengingTheImpossible");         // get album list of a page using page alias
            page.GetPageReviewInfo(pageIdOrAlias: "FHNChallengingTheImpossible"); // get review of pages
            page.LikePage(pageIdOrAlias: "FHNChallengingTheImpossible");          // like a page
            page.GetPageAlbumImages(pageAlias: "FHNChallengingTheImpossible", albumId: "568853546917720");

            // messy stuff
            // I'm not sure we can use this method for user or group posts. Not tested yet.
            page.CommentToPageAlbumImage("https://m.facebook.com/photo.php?fbid=569190373550704&id=533880033748405", "Hi");
            page.LikePhoto(targetId: "target id is photo picture in a page."); // hmm

            // Group end-point
            var group = new GroupEndpoint(username: "", password: "");

            group.GetJoinedGroups();
            group.Post(message: "hello I'm new", groupId: "1234567");
            group.JoinGroup(groupId: "1234567");
            group.CancelJoinGroup(groupId: "1234567"); // incase your join group is pending for processing
            group.LeaveGroup(groupId: "1234567", preventReAdd: true);
            group.GetGroupInfo(groupId: "1234567");    // get group information, member list, admin, etc...

            Console.WriteLine();
        }
Пример #30
0
        /// <summary>
        /// Retrieves the application configuration and begins running the
        /// sample.
        /// </summary>
        private void Run()
        {
            try
            {
                // Prepare and instantiate the platform.
                _helper = new UCMASampleHelper();
                UserEndpointSettings userEndpointSettings = _helper.ReadUserSettings(
                    "PublishPresence Sample User" /*friendly name of the sample's user endpoint*/);

                // Set auto subscription to LocalOwnerPresence.
                userEndpointSettings.AutomaticPresencePublicationEnabled = true;
                _userEndpoint = _helper.CreateUserEndpoint(userEndpointSettings);

                // LocalOwnerPresence is the main class to manage the
                // sample user's presence data.
                _localOwnerPresence = _userEndpoint.LocalOwnerPresence;

                // Wire up handlers to receive presence notifications to self.
                _localOwnerPresence.PresenceNotificationReceived
                    += LocalOwnerPresence_PresenceNotificationReceived;

                // Establish the endpoint.
                _helper.EstablishUserEndpoint(_userEndpoint);

                // Publish presence categories with the new values that
                // are outlined in the sample.
                PublishPresenceCategories(true /* publish presence categories */);
                Console.WriteLine("Note, AggregateState, and ContactCard published.");

                // Wait for user to continue.
                UCMASampleHelper.PauseBeforeContinuing(
                    "Press ENTER to continue and delete the published presence.");

                // Delete presence categories, returning them to the original
                // values before the sample was run.
                PublishPresenceCategories(false /* delete presence categories */);

                // Wait for user to continue.
                UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shutdown and exit.");

                // Un-wire the presence notification event handler.
                _localOwnerPresence.PresenceNotificationReceived
                    -= LocalOwnerPresence_PresenceNotificationReceived;
            }
            finally
            {
                // Shut down platform before exiting the sample.
                _helper.ShutdownPlatform();
            }
        }
        public void loginLyncServer()
        {
            // Connect to Lync Server
            userEndpoint = SampleCommon.ConnectLyncServer(sipUri.ToString(),
                                                          SampleCommon.LyncServer,
                                                          SampleCommon.UsingSso,
                                                          userDomanName,
                                                          password);

            // Connect to Persistent Chat Server
            persistentChatEndpoint = SampleCommon.ConnectPersistentChatServer(userEndpoint, SampleCommon.PersistentChatServerUri);
            Console.WriteLine(String.Format("please press any key continue login success    [{0}]...", userName));
            Console.ReadLine();
        }
Пример #32
0
        protected override async void OnStart(string[] args) {
            if (!Directory.Exists(Path.Combine(ZMachineSettings.AppDataFolder, "Saves"))) {
                Directory.CreateDirectory(Path.Combine(ZMachineSettings.AppDataFolder, "Saves"));
            }
            if (!Directory.Exists(Path.Combine(ZMachineSettings.AppDataFolder, "Games"))) {
                Log.Warn("No Z-Machine games included");
                Directory.CreateDirectory(Path.Combine(ZMachineSettings.AppDataFolder, "Games"));
            } else {
                if (!Directory.GetFiles(Path.Combine(ZMachineSettings.AppDataFolder, "Games")).Any()) {
                    Log.Warn("No Z-Machine games included");
                }
            }


            var clientPlatformSettings = new ClientPlatformSettings("LyncZMachine", SipTransportType.Tls);
            _collabPlatform = new CollaborationPlatform(clientPlatformSettings);
            await _collabPlatform.StartupAsync();

            _settings = new UserEndpointSettings(
                ZMachineSettings.Settings.Sip,
                ZMachineSettings.Settings.LyncServer
                //ConfigurationManager.AppSettings["sip"], 
                //ConfigurationManager.AppSettings["LyncServer"]
            ) {
                Credential = new NetworkCredential(
                    ZMachineSettings.Settings.Username,
                    ZMachineSettings.Settings.Password,
                    ZMachineSettings.Settings.Domain
                    //ConfigurationManager.AppSettings["username"], 
                    //ConfigurationManager.AppSettings["pw"], 
                    //ConfigurationManager.AppSettings["domain"]
                ),
                AutomaticPresencePublicationEnabled = true
            };
            _settings.Presence.UserPresenceState = PresenceState.UserAvailable;

            _endpoint = new UserEndpoint(_collabPlatform, _settings);
            await _endpoint.EstablishAsync();

            _endpoint.RegisterForIncomingCall<InstantMessagingCall>(GameStarted);

            _webServer = WebApp.Start<Startup>(string.Format("http://+:{0}/ZMachine", ZMachineSettings.Settings.Port));
        }
Пример #33
0
        // Method to establish an already created UserEndpoint.
        // This method returns an established UserEndpoint object. If you do not want to monitor LocalOwnerPresence, you may 
        // want to call the CreateEstablishedUserEndpoint method directly. Otherwise, you may call ReadUserSettings
        // followed by CreateUserEndpoint, followed by EstablishUserEndpoint methods.
        public bool EstablishUserEndpoint(UserEndpoint userEndpoint)
        {
            // Startup the platform, if not already
            if (_isPlatformStarted == false)
            {
                userEndpoint.Platform.BeginStartup(EndPlatformStartup, userEndpoint.Platform);

                // Sync; wait for the platform startup to complete.
                _platformStartupCompleted.WaitOne();
                NonBlockingConsole.WriteLine("Platform started...");
                _isPlatformStarted = true;
            }
            // Establish the user endpoint
            userEndpoint.BeginEstablish(EndEndpointEstablish, userEndpoint);

            // Sync; wait for the registration to complete.
            _endpointInitCompletedEvent.WaitOne();
            NonBlockingConsole.WriteLine("Endpoint established...");
            return true;
        }
Пример #34
0
        // Method to create an endpoint given a UserEndpointSettings object.
        // This method returns a UserEndpoint object so that you can wire up Endpoint-specific event handlers. 
        // If you do not want to get endpoint specific event information at the time the endpoint is established, you may 
        // want to call the CreateEstablishedUserEndpoint method directly. Otherwise, you may call ReadUserSettings
        // followed by CreateUserEndpoint, followed by EstablishUserEndpoint methods.
        public UserEndpoint CreateUserEndpoint(UserEndpointSettings userEndpointSettings)
        {
            // Reuse platform instance so that all endpoints share the same platform.
            if (_collabPlatform == null)
            {
                // Initialize and start the platform.
                ClientPlatformSettings clientPlatformSettings = new ClientPlatformSettings(_applicationName, _transportType);
                _collabPlatform = new CollaborationPlatform(clientPlatformSettings);
            }

            _userEndpoint = new UserEndpoint(_collabPlatform, userEndpointSettings);
            return _userEndpoint;
        }
Пример #35
0
        private async void btnTest_Click(object sender, EventArgs e) {
            try {
                Cursor = Cursors.WaitCursor;
                var clientPlatformSettings = new ClientPlatformSettings("LyncZMachine", SipTransportType.Tls);
                var collabPlatform = new CollaborationPlatform(clientPlatformSettings);
                await collabPlatform.StartupAsync();

                var settings = new UserEndpointSettings(txtSip.Text, txtServer.Text) {
                    Credential = new NetworkCredential(txtUsername.Text, txtPassword.Text, txtDomain.Text),
                    AutomaticPresencePublicationEnabled = true
                };

                var endpoint = new UserEndpoint(collabPlatform, settings);

                await endpoint.EstablishAsync();
                btnSave.Enabled = true;
                MessageBox.Show("Connected successfully to " + txtServer.Text + " as " + txtSip.Text);
                try {
                    await endpoint.TerminateAsync();
                    await collabPlatform.ShutdownAsync();
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message, "An Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "An Error Occurred", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                btnSave.Enabled = false;
            } finally {
                Cursor = Cursors.Default;
            }
        }
 public void EndTerminateUserEndpoint(IAsyncResult result)
 {
     UserEndpoint endpoint = (UserEndpoint)result.AsyncState;
     try
     {
         endpoint.EndTerminate(result);
     }
     finally
     {
         _userEndpoint = null;
         this._waitForUserEndpointTerminated.Set();
     }
 }
Пример #37
0
        private async Task Establish()
        {
            Console.WriteLine("Establishing with endpoint:" + _sipaddress);

            if (!_endpointStarted)
            {
                Console.WriteLine("Collab Platform not started, starting now");
                {
                   await EstablishCollaborationPlatform();
                }
            }
                     
            var settings = new UserEndpointSettings(_sipaddress);
            settings.Credential = new System.Net.NetworkCredential(_username, _password);

            
            _endpoint = new UserEndpoint(_collabPlatform, settings);
            await _endpoint.EstablishAsync();
        }