public void onUserHoldRetrieve(int session) { IAbstractState state = this[session].State; if (state.Id == EStateId.ACTIVE) { this.getCall(session).State.holdCall(); } else if (state.Id == EStateId.HOLDING) { if (this.getNoCallsInState(EStateId.ACTIVE) > 0) { IStateMachine machine = ((List <IStateMachine>) this.enumCallsInState(EStateId.ACTIVE))[0]; if (!machine.IsNull) { machine.State.holdCall(); } this._pendingAction = new PendingAction(EPendingActions.EUserHold, session); } else { this[session].State.retrieveCall(); } } }
public void ChatNovaMensagem(ChatMessage model) { var hubContext = GetMainHub(); if (HubMapping.Instance.IsConnected(model.IdUsuario)) { var conexoes = HubMapping.Instance.GetConnections(model.IdUsuario); foreach (var item in conexoes) { // hubContext.Clients.Client(item).novaMensagem(model); } } else { //Guardar na lista de chamadas pendentes var action = new PendingAction() { MethodName = "novaMensagem", HubName = "SignalRHub", Data = model }; AdicionarChamadaPendente(model.IdUsuario, action); } }
void PerformPublish(PendingAction action, bool allowNoToken) { var accessToken = AccessToken.CurrentAccessToken; if (accessToken != null) { pendingAction = action; if (HasPublishPermission()) { HandlePendingAction(); return; } else { LoginManager.Instance.LogInWithPublishPermissions(this, PERMISSIONS); return; } } if (allowNoToken) { pendingAction = action; HandlePendingAction(); } }
/// <summary> /// User put call on hold or retrieve /// </summary> /// <param name="session">session identification</param> public void OnUserHoldRetrieve(int session) { // check Hold or Retrieve IAbstractState state = this[session].State; if (state.Id == EStateId.ACTIVE) { this[session].State.holdCall(); } else if (state.Id == EStateId.HOLDING) { // execute retrieve // check if any ACTIVE calls if (this[EStateId.ACTIVE].Count > 0) { // get 1st and put it on hold IStateMachine sm = this[EStateId.ACTIVE][0]; if (!sm.IsNull) { sm.State.holdCall(); } // set Retrieve event pending for HoldConfirm _pendingAction = new PendingAction(EPendingActions.EUserHold, session); return; } this[session].State.retrieveCall(); } else { // illegal } }
public void AsyncTaskCompleted(int usuarioId, int tipoTask, string id, string data) { var hubContext = GetMainHub(); var model = new { TipoTask = tipoTask, Id = id, Dados = data }; if (HubMapping.Instance.IsConnected(usuarioId)) { var conexoes = HubMapping.Instance.GetConnections(usuarioId); foreach (var item in conexoes) { //hubContext.Clients.Client(item).asyncTaskCompleted(model); } } else { var action = new PendingAction() { MethodName = "asyncTaskCompleted", HubName = "SignalRHub", Data = model }; AdicionarChamadaPendente(usuarioId, action); } }
private void PostPhoto() { var image = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.icon); var sharePhoto = new SharePhoto.Builder() .SetBitmap(image).Build().JavaCast <SharePhoto> (); var photos = new List <SharePhoto> (); photos.Add(sharePhoto); var sharePhotoContent = new SharePhotoContent.Builder() .SetPhotos(photos).Build(); if (canPresentShareDialogWithPhotos) { shareDialog.Show(sharePhotoContent); } else if (HasPublishPermission()) { ShareApi.Share(sharePhotoContent, shareCallback); } else { pendingAction = PendingAction.POST_PHOTO; } }
public bool NotificacaoPendente(object model, int usuarioId) { var enviado = false; var hubContext = GetMainHub(); if (HubMapping.Instance.IsConnected(usuarioId)) { var conexoes = HubMapping.Instance.GetConnections(usuarioId); foreach (var item in conexoes) { // hubContext.Clients.Client(item).notificacao(model); } enviado = true; } else { var action = new PendingAction() { MethodName = "notificacaoPendente", HubName = "SignalRHub", Data = model }; AdicionarChamadaPendente(usuarioId, action); } return(enviado); }
/// <summary> /// User put call on hold or retrieve /// </summary> /// <param name="session">session identification</param> public void onUserHoldRetrieve(int session) { // check Hold or Retrieve CAbstractState state = this[session].getState(); if (state.StateId == EStateId.ACTIVE) { this.getCall(session).getState().holdCall(session); } else if (state.StateId == EStateId.HOLDING) { // execute retrieve // check if any ACTIVE calls if (this.getNoCallsInState(EStateId.ACTIVE) > 0) { // get 1st and put it on hold CStateMachine sm = ((List <CStateMachine>)enumCallsInState(EStateId.ACTIVE))[0]; if (null != sm) { sm.getState().holdCall(sm.Session); } // set Retrieve event pending for HoldConfirm _pendingAction = new PendingAction(EPendingActions.EUserHold, session); return; } this[session].getState().retrieveCall(session); } else { // illegal } }
private void PostPhoto() { Bitmap image = BitmapFactory.DecodeResource(Resources, Resource.Drawable.icon); SharePhoto sharePhoto = (SharePhoto) new SharePhoto.Builder().SetBitmap(image).Build(); IList <SharePhoto> photos = new List <SharePhoto>(); photos.Add(sharePhoto); SharePhotoContent sharePhotoContent = new SharePhotoContent.Builder().SetPhotos(photos).Build(); if (canPresentShareDialogWithPhotos) { shareDialog.Show(sharePhotoContent); } else if (HasPublishPermission()) { ShareApi.Share(sharePhotoContent, shareCallback); } else { pendingAction = PendingAction.POST_PHOTO; // We need to get new permissions, then complete the action when we get called back. LoginManager.Instance.LogInWithPublishPermissions(this, PERMISSION); } }
private void Device_Connected(Device obj) { lock (pendingActionLocker) { if (PendingAction != null) { PendingAction.Invoke(); PendingAction = null; } else { //在程序还没退出,连接再次恢复的时候,会自动进入这个函数。 if (IsStarted) { if (IsAutoRecoverable) { Recover(); } else { //不需要恢复,直接把状态从Error改成Running. 继续处理对方发过来的消息就行了。 State = RequesterState.Running; } } } } }
public void AddPendingAction(PendingAction action) { if (action.Action == null) { Debug.LogWarning("Invalid action: Action is null."); return; } if (action.LayerIndex == null || action.LayerWeight == null) { Debug.LogWarning("Null array(s?): layer index or weight."); return; } if (action.LayerIndex.Length != action.LayerWeight.Length) { Debug.LogWarning("Layer index / weight array length mismatch."); return; } for (int i = 0; i < action.LayerIndex.Length; i++) { if (action.LayerIndex[i] <= 0 || action.LayerIndex[i] >= Animator.layerCount) { Debug.LogWarning($"Action for layer {action.LayerIndex} is invalid: this index is out of bounds. (min 1, max {Animator.layerCount - 1})"); return; } if (action.LayerWeight[i] < 0f || action.LayerWeight[i] >= 1f) { Debug.LogWarning($"Action has invalid target weight: {action.LayerWeight}. This will be clamped to the 0-1 range."); action.LayerWeight[i] = Mathf.Clamp01(action.LayerWeight[i]); } } actions.Add(action); }
public void activatePendingAction() { if (this._pendingAction != null) { this._pendingAction.Activate(); } this._pendingAction = null; }
/// <summary> /// /// </summary> internal void activatePendingAction() { if (null != _pendingAction) { _pendingAction.Activate(); } _pendingAction = null; }
private void CallPendingMethod(PendingAction action, string[] conexoes) { var hubContext = _hubContext; var proxy = hubContext.Clients.Clients(conexoes); proxy.SendAsync(action.MethodName, action.Data); }
/// <summary> /// Create outgoing call from a given account. /// </summary> /// <param name="number">Number to call</param> /// <param name="accountId">Specified account Id </param> public IStateMachine createOutboundCall(string number, int accountId) { if (!IsInitialized) { return(new NullStateMachine()); } // check if current call automatons allow session creation. if (this.getNoCallsInStates((int)(EStateId.CONNECTING | EStateId.ALERTING)) > 0) { // new call not allowed! return(new NullStateMachine()); } // if at least 1 connected try to put it on hold if (this.getNoCallsInState(EStateId.ACTIVE) == 0) { // create state machine IStateMachine call = Factory.createStateMachine(); // couldn't create new call instance (max calls?) if (call == null) { return(null); } // make call request (stack provides new sessionId) int newsession = call.State.makeCall(number, accountId); if (newsession == -1) { return(new NullStateMachine()); } // update call table // catch argument exception (same key)!!!! try { call.Session = newsession; _calls.Add(newsession, call); } catch (ArgumentException e) { // previous call not released () // first release old one _calls[newsession].destroy(); // and then add new one _calls.Add(newsession, call); } return(call); } else // we have at least one ACTIVE call { // put connected call on hold // TODO pending action _pendingAction = new PendingAction(EPendingActions.ECreateSession, number, accountId); IStateMachine call = getCallInState(EStateId.ACTIVE); call.State.holdCall(); } return(new NullStateMachine()); }
private void PerformPublish(PendingAction action, bool allowNoToken) { AccessToken accessToken = AccessToken.CurrentAccessToken; if (accessToken != null || allowNoToken) { pendingAction = action; HandlePendingAction(); } }
private void PostStatusUpdate() { if (user != null && HasPublishPermission()) { string message = GetString(Resource.String.status_update, user.FirstName, (DateTime.Now.ToString())); Request request = Request.NewStatusUpdateRequest(Session.ActiveSession, message, new RequestCallback(response => ShowPublishResult(message, response.GraphObject, response.Error))); request.ExecuteAsync(); } else { pendingAction = PendingAction.POST_STATUS_UPDATE; } }
private void PostPhoto() { if (HasPublishPermission()) { Bitmap image = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.icon); Request request = Request.NewUploadPhotoRequest(Session.ActiveSession, image, new RequestCallback(response => { ShowPublishResult(GetString(Resource.String.photo_post), response.GraphObject, response.Error); })); request.ExecuteAsync(); } else { pendingAction = PendingAction.POST_PHOTO; } }
protected override void CheckPendingActions(IThing thingChanged, ThingStateChangedEventArgs eventArgs) { if (PendingAction == null || thingChanged != this || eventArgs.PropertyChanged != nameof(Location)) { return; } if (Location == PendingAction.RetryLocation) { Task.Delay(CalculateRemainingCooldownTime(CooldownType.Action, DateTime.Now) + TimeSpan.FromMilliseconds(500)) .ContinueWith(previous => { PendingAction.Perform(); }); } }
private void AdicionarChamadaPendente(int usuarioId, PendingAction action) { lock (pendingActions) { List <PendingAction> actionsUsuario = null; if (!pendingActions.TryRemove(usuarioId, out actionsUsuario)) { actionsUsuario = new List <PendingAction>(); } action.Timestamp = DateTime.UtcNow; actionsUsuario.Add(action); pendingActions.TryAdd(usuarioId, actionsUsuario.Where(a => a.Timestamp >= DateTime.UtcNow.AddMinutes(-1)).ToList()); } }
public void onUserAnswer(int session) { List <IStateMachine> list = (List <IStateMachine>) this.enumCallsInState(EStateId.ACTIVE); if (list.Count > 0) { IStateMachine machine = list[0]; if (!machine.IsNull) { machine.State.holdCall(); } this._pendingAction = new PendingAction(EPendingActions.EUserAnswer, session); } else { this[session].State.acceptCall(); } }
private void HandlePendingAction() { PendingAction previouslyPendingAction = _pendingAction; // These actions may re-set pendingAction if they are still pending, but we assume they // will succeed. _pendingAction = PendingAction.NONE; switch (previouslyPendingAction) { case PendingAction.POST_PHOTO: break; case PendingAction.POST_STATUS_UPDATE: PostStatusUpdate(); break; } }
private void OnSessionStateChange(Session session, SessionState state, Exception exception) { if (pendingAction != PendingAction.NONE && (exception is FacebookOperationCanceledException || exception is FacebookAuthorizationException)) { new AlertDialog.Builder(this) .SetTitle(Resource.String.cancelled) .SetMessage(Resource.String.permission_not_granted) .SetPositiveButton(Resource.String.ok, (object sender, DialogClickEventArgs e) => {}) .Show(); pendingAction = PendingAction.NONE; } else if (state == SessionState.OpenedTokenUpdated) { HandlePendingAction(); } UpdateUI(); }
private void PerformPublish(PendingAction action) { Session session = Session.ActiveSession; if (session != null) { pendingAction = action; if (HasPublishPermission()) { // We can do the action right away. HandlePendingAction(); } else { // We need to get new permissions, then complete the action when we get called back. session.RequestNewPublishPermissions(new Session.NewPermissionsRequest(this, PERMISSIONS)); } } }
//TODO: !!!!PostStatusUpdate public void PostStatusUpdate() { if (_user != null && HasPublishPermission()) { Request request = Request.NewStatusUpdateRequest(Session.ActiveSession, _textMessage.Text, new RequestCallback(response => ShowPublishResult("Ok", response.GraphObject, response.Error))); Bundle parameters = request.Parameters; parameters.PutString("link", Constants.StoreSearchLink); parameters.PutString("caption", Constants.CaptionName); parameters.PutString("description", _message); parameters.PutString("name", "Big Days of Our Lives Countdown for Android"); parameters.PutString("picture", "https://fbcdn-photos-g-a.akamaihd.net/hphotos-ak-xfa1/t39.2081-0/p128x128/10333116_436546179825969_1893993755_n.png"); request.ExecuteAsync(); } else { _pendingAction = PendingAction.POST_STATUS_UPDATE; } }
/// <summary> /// User accepts call for a given session /// In case of multi call put current active call to Hold /// </summary> /// <param name="session">session identification</param> public void OnUserAnswer(int session) { List <IStateMachine> list = this[EStateId.ACTIVE]; // should not be more than 1 call active if (list.Count > 0) { // put it on hold IStateMachine sm = list[0]; if (!sm.IsNull) { sm.State.holdCall(); } // set ANSWER event pending for HoldConfirm _pendingAction = new PendingAction(EPendingActions.EUserAnswer, session); return; } this[session].State.acceptCall(); }
/// <summary> /// Hold calls in active state, but not in conference /// </summary> /// <param name="pendingAction">Action to make after the call putted on hold</param> private void HoldActiveCalls(PendingAction pendingAction) { if (this[EStateId.ACTIVE].Count > 0) { foreach (var sm in this[EStateId.ACTIVE]) { if (!sm.IsConference) { // get 1st and put it on hold if (!sm.IsNull) { sm.State.holdCall(); } // set Retrieve event pending for HoldConfirm _pendingAction = pendingAction; return; } } } }
/// <summary> /// User accepts call for a given session /// In case of multi call put current active call to Hold /// </summary> /// <param name="session">session identification</param> public void onUserAnswer(int session) { List <CStateMachine> list = (List <CStateMachine>) this.enumCallsInState(EStateId.ACTIVE); // should not be more than 1 call active if (list.Count > 0) { // put it on hold CStateMachine sm = list[0]; if (null != sm) { sm.getState().holdCall(sm.Session); } // set ANSWER event pending for HoldConfirm // TODO _pendingAction = new PendingAction(EPendingActions.EUserAnswer, session); return; } this[session].getState().acceptCall(session); }
private void PostStatusUpdate() { var profile = Profile.CurrentProfile; ShareLinkContent linkContent = new ShareLinkContent.Builder() .SetContentTitle("Hello Facebook") .SetContentDescription("The 'Hello Facebook' sample showcases simple Facebook integration") .SetImageUrl(Uri.Parse("http://developers.facebook.com/docs/android")) .Build(); if (canPresentShareDialog) { shareDialog.Show(linkContent); } else if (profile != null && HasPublishPermission()) { ShareApi.Share(linkContent, shareCallback); } else { pendingAction = PendingAction.POST_STATUS_UPDATE; } }
public void SwitchAction(string actionName) { //if (PendingAction != null) //{ // PendingAction.OnDeactivate(); // PendingAction.DisconnectInputs(); //} if (CurrentAction != null) { CurrentAction.OnDeactivate(); CurrentAction.DisconnectInputs(); } CurrentAction = ModifierContainer.Get(actionName); CurrentAction.Setup(); CurrentAction.OnActivate(); if (OnSwitchAction != null) { OnSwitchAction(); } if (actionName == ModifierNames.None && PendingAction != null && PendingAction.Name != ModifierNames.None) { if (CurrentAction != null) { CurrentAction.OnDeactivate(); CurrentAction.DisconnectInputs(); } PendingAction.Setup(); PendingAction.OnActivate(); if (OnSwitchAction != null) { OnSwitchAction(); } PendingAction = ModifierContainer.Get(ModifierNames.None); //return; } }
/// <summary> /// Create outgoing call from a given account. /// </summary> /// <param name="number">Number to call</param> /// <param name="accountId">Specified account Id </param> public IStateMachine createOutboundCall(string number, int accountId) { if (!IsInitialized) return new NullStateMachine(); // check if current call automatons allow session creation. if (this.getNoCallsInStates((int)(EStateId.CONNECTING | EStateId.ALERTING)) > 0) { // new call not allowed! return new NullStateMachine(); } // if at least 1 connected try to put it on hold if (this.getNoCallsInState(EStateId.ACTIVE) == 0) { // create state machine IStateMachine call = Factory.createStateMachine(); // couldn't create new call instance (max calls?) if (call == null) { return null; } // make call request (stack provides new sessionId) int newsession = call.State.makeCall(number, accountId); if (newsession == -1) { return new NullStateMachine(); } // update call table // catch argument exception (same key)!!!! try { call.Session = newsession; _calls.Add(newsession, call); } catch (ArgumentException e) { // previous call not released () // first release old one _calls[newsession].destroy(); // and then add new one _calls.Add(newsession, call); } return call; } else // we have at least one ACTIVE call { // put connected call on hold // TODO pending action _pendingAction = new PendingAction(EPendingActions.ECreateSession, number, accountId); IStateMachine call = getCallInState(EStateId.ACTIVE); call.State.holdCall(); } return new NullStateMachine(); }
/// <summary> /// Create outgoing call to a number and from a given account. /// /// If the other calls exist check if it is possible to create a new one. /// The logic below will automatically put the active call on hold, /// return -2 and store a new call creation request. When hold confirmation /// received create a call. /// /// Be aware: This is done asynchronously. /// /// </summary> /// <param name="number">Number to call</param> /// <param name="accountId">Specified account Id </param> public int CreateSmartOutboundCall(string number, int accountId) { if (!IsInitialized) return -1; // check if current call automatons allow session creation. if (this.GetNoCallsInStates((int)(EStateId.CONNECTING | EStateId.ALERTING)) > 0) { // new call not allowed! return -1; } // if at least 1 call connected try to put it on hold first if (this[EStateId.ACTIVE].Count == 0) { // create state machine IStateMachine call = Factory.createStateMachine(); // couldn't create new call instance (max calls?) if (call == null) { return -1; } // make call request (stack provides new sessionId) int newsession = call.State.makeCall(number, accountId); if (newsession == -1) { return -1; } // update call table // catch argument exception (same key)!!!! try { call.Session = newsession; _calls.Add(newsession, call); } catch (ArgumentException e) { // previous call not released () // first release old one _calls[newsession].Destroy(); // and then add new one _calls.Add(newsession, call); } return call.Session; } else // we have at least one ACTIVE call { // put connected call on hold _pendingAction = new PendingAction(EPendingActions.ECreateSession, number, accountId); List<IStateMachine> calls = this[EStateId.ACTIVE]; if (calls.Count > 0) { calls[0].State.holdCall(); } // indicates that new call is pending... // At this point we don't know yet if the call will be created or not // The call will be created when current call is put on hold (confirmation)! return -2; } }
private void HandlePendingAction() { PendingAction previouslyPendingAction = _pendingAction; // These actions may re-set pendingAction if they are still pending, but we assume they // will succeed. _pendingAction = PendingAction.NONE; }
private void PerformPublish (PendingAction action) { Session session = Session.ActiveSession; if (session != null) { pendingAction = action; if (HasPublishPermission ()) { // We can do the action right away. HandlePendingAction (); } else { // We need to get new permissions, then complete the action when we get called back. session.RequestNewPublishPermissions (new Session.NewPermissionsRequest (this, PERMISSIONS)); } } }
/// <summary> /// User accepts call for a given session /// In case of multi call put current active call to Hold /// </summary> /// <param name="session">session identification</param> public void OnUserAnswer(int session) { List<IStateMachine> list = this[EStateId.ACTIVE]; // should not be more than 1 call active if (list.Count > 0) { // put it on hold IStateMachine sm = list[0]; if (!sm.IsNull) sm.State.holdCall(); // set ANSWER event pending for HoldConfirm _pendingAction = new PendingAction(EPendingActions.EUserAnswer, session); return; } this[session].State.acceptCall(); }
private void PostStatusUpdate () { if (user != null && HasPublishPermission ()) { string message = GetString (Resource.String.status_update, user.FirstName, (DateTime.Now.ToString ())); Request request = Request.NewStatusUpdateRequest (Session.ActiveSession, message, new RequestCallback (response => ShowPublishResult (message, response.GraphObject, response.Error))); request.ExecuteAsync (); } else { pendingAction = PendingAction.POST_STATUS_UPDATE; } }
private void PostPhoto () { if (HasPublishPermission ()) { Bitmap image = BitmapFactory.DecodeResource (this.Resources, Resource.Drawable.icon); Request request = Request.NewUploadPhotoRequest (Session.ActiveSession, image, new RequestCallback (response => { ShowPublishResult (GetString (Resource.String.photo_post), response.GraphObject, response.Error); })); request.ExecuteAsync (); } else { pendingAction = PendingAction.POST_PHOTO; } }
private void OnSessionStateChange (Session session, SessionState state, Exception exception) { if (pendingAction != PendingAction.NONE && (exception is FacebookOperationCanceledException || exception is FacebookAuthorizationException)) { new AlertDialog.Builder (this) .SetTitle (Resource.String.cancelled) .SetMessage (Resource.String.permission_not_granted) .SetPositiveButton (Resource.String.ok, (object sender, DialogClickEventArgs e) => {}) .Show (); pendingAction = PendingAction.NONE; } else if (state == SessionState.OpenedTokenUpdated) { HandlePendingAction (); } UpdateUI (); }
private void HandlePendingAction () { PendingAction previouslyPendingAction = pendingAction; // These actions may re-set pendingAction if they are still pending, but we assume they // will succeed. pendingAction = PendingAction.NONE; switch (previouslyPendingAction) { case PendingAction.POST_PHOTO: PostPhoto (); break; case PendingAction.POST_STATUS_UPDATE: PostStatusUpdate (); break; } }
/// <summary> /// User put call on hold or retrieve /// </summary> /// <param name="session">session identification</param> public void OnUserHoldRetrieve(int session) { // check Hold or Retrieve IAbstractState state = this[session].State; if (state.Id == EStateId.ACTIVE) { this[session].State.holdCall(); } else if (state.Id == EStateId.HOLDING) { // execute retrieve // check if any ACTIVE calls if (this[EStateId.ACTIVE].Count > 0) { // get 1st and put it on hold IStateMachine sm = this[EStateId.ACTIVE][0]; if (!sm.IsNull) sm.State.holdCall(); // set Retrieve event pending for HoldConfirm _pendingAction = new PendingAction(EPendingActions.EUserHold, session); return; } this[session].State.retrieveCall(); } else { // illegal } }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); uiHelper = new UiLifecycleHelper (this, callback); uiHelper.OnCreate (savedInstanceState); if (savedInstanceState != null) { string name = savedInstanceState.GetString (PENDING_ACTION_BUNDLE_KEY); pendingAction = (PendingAction)Enum.Parse (typeof(PendingAction), name); } SetContentView (Resource.Layout.main); loginButton = (LoginButton)FindViewById (Resource.Id.login_button); loginButton.UserInfoChangedCallback = new MyUserInfoChangedCallback (this); profilePictureView = FindViewById<ProfilePictureView> (Resource.Id.profilePicture); greeting = FindViewById<TextView> (Resource.Id.greeting); postStatusUpdateButton = FindViewById<Button> (Resource.Id.postStatusUpdateButton); postStatusUpdateButton.Click += delegate { OnClickPostStatusUpdate (); }; postPhotoButton = (Button)FindViewById (Resource.Id.postPhotoButton); postPhotoButton.Click += delegate { OnClickPostPhoto (); }; pickFriendsButton = (Button)FindViewById (Resource.Id.pickFriendsButton); pickFriendsButton.Click += delegate { OnClickPickFriends (); }; pickPlaceButton = (Button)FindViewById (Resource.Id.pickPlaceButton); pickPlaceButton.Click += delegate { OnClickPickPlace (); }; controlsContainer = (ViewGroup)FindViewById (Resource.Id.main_ui_container); FragmentManager fm = SupportFragmentManager; Fragment fragment = fm.FindFragmentById (Resource.Id.fragment_container); if (fragment != null) { // If we're being re-created and have a fragment, we need to a) hide the main UI controls and // b) hook up its listeners again. controlsContainer.Visibility = ViewStates.Gone; if (fragment is FriendPickerFragment) { SetFriendPickerListeners ((FriendPickerFragment)fragment); } else if (fragment is PlacePickerFragment) { SetPlacePickerListeners ((PlacePickerFragment)fragment); } } fm.BackStackChanged += delegate { if (fm.BackStackEntryCount == 0) { // We need to re-show our UI. controlsContainer.Visibility = ViewStates.Visible; } }; }
/// <summary> /// /// </summary> internal void activatePendingAction() { if (null != _pendingAction) _pendingAction.Activate(); _pendingAction = null; }
/// <summary> /// /// </summary> public void activatePendingAction() { if (null != _pendingAction) _pendingAction.Activate(); _pendingAction = null; }
/// <summary> /// User put call on hold or retrieve /// </summary> /// <param name="session">session identification</param> public void onUserHoldRetrieve(int session) { // check Hold or Retrieve CAbstractState state = this[session].getState(); if (state.StateId == EStateId.ACTIVE) { this.getCall(session).getState().holdCall(session); } else if (state.StateId == EStateId.HOLDING) { // execute retrieve // check if any ACTIVE calls if (this.getNoCallsInState(EStateId.ACTIVE) > 0) { // get 1st and put it on hold CStateMachine sm = ((List<CStateMachine>)enumCallsInState(EStateId.ACTIVE))[0]; if (null != sm) sm.getState().holdCall(sm.Session); // set Retrieve event pending for HoldConfirm _pendingAction = new PendingAction(EPendingActions.EUserHold, session); return; } this[session].getState().retrieveCall(session); } else { // illegal } }
/// <summary> /// User accepts call for a given session /// In case of multi call put current active call to Hold /// </summary> /// <param name="session">session identification</param> public void onUserAnswer(int session) { List<CStateMachine> list = (List<CStateMachine>)this.enumCallsInState(EStateId.ACTIVE); // should not be more than 1 call active if (list.Count > 0) { // put it on hold CStateMachine sm = list[0]; if (null != sm) sm.getState().holdCall(sm.Session); // set ANSWER event pending for HoldConfirm // TODO _pendingAction = new PendingAction(EPendingActions.EUserAnswer, session); return; } this[session].getState().acceptCall(session); }
/// <summary> /// Handler for outgoing calls (sessionId is not known yet). /// </summary> /// <param name="number">Number to call</param> /// <param name="accountId">Specified account Id </param> public CStateMachine createOutboundCall(string number, int accountId) { // check if current call automatons allow session creation. if (this.getNoCallsInStates((int)(EStateId.CONNECTING | EStateId.ALERTING)) > 0) { // new call not allowed! return null; } // if at least 1 connected try to put it on hold if (this.getNoCallsInState(EStateId.ACTIVE) == 0) { // create state machine // TODO check max calls!!!! CStateMachine call = new CStateMachine(this); // make call request (stack provides new sessionId) int newsession = call.getState().makeCall(number, accountId); if (newsession == -1) { return null; } // update call table // TODO catch argument exception (same key)!!!! call.Session = newsession; _calls.Add(newsession, call); return call; } else // we have at least one ACTIVE call { // put connected call on hold // TODO pending action _pendingAction = new PendingAction(EPendingActions.ECreateSession, number, accountId); CStateMachine call = getCallInState(EStateId.ACTIVE); call.getState().holdCall(call.Session); } return null; }