Beispiel #1
0
        public void ChannelGroupPresenceRevoke()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.RevokeChannelGroupPresence, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #2
0
        public void ChannelGroupSubscribeAudit()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.AuditChannelGroupSubscribe, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #3
0
        public void PresenceAudit()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.AuditPresence, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #4
0
        void SetPresenceHeartbeat()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.PresenceHeartbeat, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #5
0
        public void AuthKey()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.Auth, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #6
0
        void AddUserStateKeyPair()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.AddUserStateKeyValue, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #7
0
        public void SubscribeRevoke()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.RevokeSubscribe, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #8
0
        void SetUserStateJson()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.SetUserStateJson, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #9
0
        void DeleteUserState()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.DeleteUserState, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #10
0
        void WhereNow()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.WhereNow, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #11
0
        void ChangeUuid()
        {
            var dialog = new CommonDialogFragment(CommonDialogStates.ChangeUuid, this);

            dialog.SetValues += HandleSetValues;
            dialog.Show(SupportFragmentManager, "dialog");
        }
Beispiel #12
0
 public void ChannelGroupSubscribeAudit()
 {
     var dialog = new CommonDialogFragment (CommonDialogStates.AuditChannelGroupSubscribe, this);
     dialog.SetValues += HandleSetValues;
     dialog.Show (SupportFragmentManager, "dialog");
 }
Beispiel #13
0
 public void PresenceAudit ()
 {
     var dialog = new CommonDialogFragment (CommonDialogStates.AuditPresence, this);
     dialog.SetValues += HandleSetValues;
     dialog.Show (SupportFragmentManager, "dialog");
 }
Beispiel #14
0
 public void SubscribeRevoke ()
 {
     var dialog = new CommonDialogFragment (CommonDialogStates.RevokeSubscribe, this);
     dialog.SetValues += HandleSetValues;
     dialog.Show (SupportFragmentManager, "dialog");
 }
Beispiel #15
0
 void SetPresenceHeartbeat ()
 {
     var dialog = new CommonDialogFragment (CommonDialogStates.PresenceHeartbeat, this);
     dialog.SetValues += HandleSetValues;
     dialog.Show (SupportFragmentManager, "dialog");
 }
Beispiel #16
0
 void AddUserStateKeyPair ()
 {
     var dialog = new CommonDialogFragment (CommonDialogStates.AddUserStateKeyValue, this);
     dialog.SetValues += HandleSetValues;
     dialog.Show (SupportFragmentManager, "dialog");
 }
Beispiel #17
0
        /*void ViewLocalUserState ()
        {
            string[] channels = channel.Split (',');
            foreach (string channelToCall in channels) {
                string currentUserStateView = pubnub.GetLocalUserState (channelToCall);
                if (!string.IsNullOrEmpty (currentUserStateView)) {
                    Display (string.Format("User state for channel {0}:{1}", channelToCall, currentUserStateView));
                } else {
                    Display (string.Format("No User State Exists for channel {0}", channelToCall));
                }
            }
        }*/

        void DeleteUserState ()
        {
            var dialog = new CommonDialogFragment (CommonDialogStates.DeleteUserState, this);
            dialog.SetValues += HandleSetValues;
            dialog.Show (SupportFragmentManager, "dialog");
        }
Beispiel #18
0
 void SetUserStateJson ()
 {
     var dialog = new CommonDialogFragment (CommonDialogStates.SetUserStateJson, this);
     dialog.SetValues += HandleSetValues;
     dialog.Show (SupportFragmentManager, "dialog");
 }
Beispiel #19
0
 void WhereNow ()
 {
     var dialog = new CommonDialogFragment (CommonDialogStates.WhereNow, this);
     dialog.SetValues += HandleSetValues;
     dialog.Show (SupportFragmentManager, "dialog");
 }
Beispiel #20
0
 void ChangeUuid ()
 {
     var dialog = new CommonDialogFragment (CommonDialogStates.ChangeUuid, this);
     dialog.SetValues += HandleSetValues;
     dialog.Show (SupportFragmentManager, "dialog");
 }
Beispiel #21
0
        void HandleSetValues(object sender, EventArgs ea)
        {
            try {
                SetEventArgs cea = ea as SetEventArgs;

                if (cea.cds == CommonDialogStates.AuditSubscribe)
                {
                    Display("Running Channel Subscribe Audit");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.Audit()
                                                 .Channel(cea.channel)
                                                 .AuthKeys(new [] { cea.valueToSet })
                                                 .Async(new DemoAuditResult(Display))
                                                 );
                }
                else if (cea.cds == CommonDialogStates.RevokeSubscribe)
                {
                    Display("Running Subscribe Revoke");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.Grant().Channels(new [] { cea.channel })
                                                 .ChannelGroups(new [] { cea.valueToSet })
                                                 .Read(false).Write(false)
                                                 .Async(new DemoGrantResult(Display))
                                                 );
                }
                else if (cea.cds == CommonDialogStates.ChangeUuid)
                {
                    Display("Setting UUID");
                    pubnub.ChangeUUID(cea.valueToSet);
                    Display(string.Format("UUID set to {0}", config.Uuid));
                }
                else if (cea.cds == CommonDialogStates.WhereNow)
                {
                    Display("Running where now");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.WhereNow().Uuid(cea.valueToSet)
                                                 .Async(new DemoWhereNowResult(Display))
                                                 );
                }
                else if (cea.cds == CommonDialogStates.GetUserState)
                {
                    Display("Running get user state");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.GetPresenceState()
                                                 .Channels(new [] { cea.channel })
                                                 .ChannelGroups(new [] { cea.channelGroup })
                                                 .Uuid(cea.valueToSet)
                                                 .Async(new DemoPNGetStateResult(Display))
                                                 );
                }
                else if (cea.cds == CommonDialogStates.DeleteUserState)
                {
                    Display("Running delete user state");
                    ThreadPool.QueueUserWorkItem(o => {
                        Dictionary <string, object> delDic = new Dictionary <string, object> ();
                        delDic.Add(cea.valueToSet, null);
                        pubnub.SetPresenceState()
                        .Channels(new [] { cea.channel })
                        .ChannelGroups(new [] { cea.channelGroup })
                        .State(delDic)
                        .Async(new DemoPNSetStateResult(Display));
                    }
                                                 );
                }
                else if (cea.cds == CommonDialogStates.AddUserStateKeyValue)
                {
                    int    valueInt;
                    double valueDouble;

                    if (Int32.TryParse(cea.valueToSet2, out valueInt))
                    {
                        ThreadPool.QueueUserWorkItem(o => {
                            Dictionary <string, object> dicInt = new Dictionary <string, object> ();
                            dicInt.Add(cea.valueToSet, valueInt);

                            pubnub.SetPresenceState()
                            .Channels(new [] { cea.channel })
                            .ChannelGroups(new [] { cea.channelGroup })
                            .State(dicInt)
                            .Async(new DemoPNSetStateResult(Display));
                        }
                                                     );
                    }
                    else if (Double.TryParse(cea.valueToSet2, out valueDouble))
                    {
                        ThreadPool.QueueUserWorkItem(o => {
                            Dictionary <string, object> dicDouble = new Dictionary <string, object> ();
                            dicDouble.Add(cea.valueToSet, valueDouble);

                            pubnub.SetPresenceState()
                            .Channels(new [] { cea.channel })
                            .ChannelGroups(new [] { cea.channelGroup })
                            .State(dicDouble)
                            .Async(new DemoPNSetStateResult(Display));
                        }
                                                     );
                    }
                    else
                    {
                        ThreadPool.QueueUserWorkItem(o => {
                            Dictionary <string, object> dicStr = new Dictionary <string, object> ();
                            dicStr.Add(cea.valueToSet, cea.valueToSet2);

                            pubnub.SetPresenceState()
                            .Channels(new [] { cea.channel })
                            .ChannelGroups(new [] { cea.channelGroup })
                            .State(dicStr)
                            .Async(new DemoPNSetStateResult(Display));
                        });
                    }
                }
            } catch (Exception ex) {
                Display(ex.Message);
            } finally {
                CommonDialogFragment coroutine = sender as CommonDialogFragment;
                coroutine.SetValues -= HandleSetValues;
            }
        }
Beispiel #22
0
 public void ChannelGroupPresenceRevoke()
 {
     var dialog = new CommonDialogFragment (CommonDialogStates.RevokeChannelGroupPresence, this);
     dialog.SetValues += HandleSetValues;
     dialog.Show (SupportFragmentManager, "dialog");
 }
Beispiel #23
0
        void HandleSetValues(object sender, EventArgs ea)
        {
            try {
                SetEventArgs cea = ea as SetEventArgs;

                if (cea.cds == CommonDialogStates.Auth)
                {
                    Display("Setting Auth Key");
                    pubnub.AuthenticationKey = cea.valueToSet;
                    Display("Auth Key set");
                }
                else if (cea.cds == CommonDialogStates.AuditSubscribe)
                {
                    Display("Running Channel Subscribe Audit");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.AuditAccess <string> (cea.channel, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.AuditPresence)
                {
                    Display("Running Presence Audit");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.AuditPresenceAccess <string> (cea.channel, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.AuditChannelGroupSubscribe)
                {
                    Display("Running ChannelGroup Subscribe Audit");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.ChannelGroupAuditAccess <string> (cea.channelGroup, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.AuditChannelGroupPresence)
                {
                    Display("Running ChannelGroup Presence Audit");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.ChannelGroupAuditPresenceAccess <string> (cea.channelGroup, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.RevokePresence)
                {
                    Display("Running Presence Revoke");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.GrantPresenceAccess <string> (cea.channel, cea.valueToSet, false, false, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.RevokeSubscribe)
                {
                    Display("Running Subscribe Revoke");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.GrantAccess <string> (cea.channel, cea.valueToSet, false, false, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.RevokeChannelGroupPresence)
                {
                    Display("Running ChannelGroup Presence Revoke");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.ChannelGroupGrantPresenceAccess <string> (cea.channelGroup, cea.valueToSet, false, false, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.RevokeChannelGroupSubscribe)
                {
                    Display("Running ChannelGroup Revoke");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.ChannelGroupGrantAccess <string> (cea.channelGroup, cea.valueToSet, false, false, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.ChangeUuid)
                {
                    Display("Setting UUID");
                    pubnub.ChangeUUID(cea.valueToSet);
                    Display(string.Format("UUID set to {0}", pubnub.SessionUUID));
                }
                else if (cea.cds == CommonDialogStates.WhereNow)
                {
                    Display("Running where now");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.WhereNow <string> (cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.GetUserState)
                {
                    Display("Running get user state");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.GetUserState <string> (cea.channel, cea.channelGroup, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.DeleteUserState)
                {
                    Display("Running delete user state");
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.SetUserState <string> (cea.channel, cea.channelGroup, new KeyValuePair <string, object> (cea.valueToSet, null), DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
                else if (cea.cds == CommonDialogStates.PresenceHeartbeat)
                {
                    Display("Setting presence heartbeat");
                    //int check done in CommonDialogFragment
                    pubnub.PresenceHeartbeat = int.Parse(cea.valueToSet);

                    Display(string.Format("PresenceHeartbeat set to {0}", pubnub.PresenceHeartbeat));
                }
                else if (cea.cds == CommonDialogStates.PresenceHeartbeatInterval)
                {
                    Display("Setting presence interval");
                    //int check done in CommonDialogFragment
                    pubnub.PresenceHeartbeatInterval = int.Parse(cea.valueToSet);
                    Display(string.Format("PresenceHeartbeatInterval set to {0}", pubnub.PresenceHeartbeatInterval));
                }
                else if (cea.cds == CommonDialogStates.AddUserStateKeyValue)
                {
                    int    valueInt;
                    double valueDouble;

                    if (Int32.TryParse(cea.valueToSet2, out valueInt))
                    {
                        ThreadPool.QueueUserWorkItem(o =>
                                                     pubnub.SetUserState <string> (cea.channel, cea.channelGroup, new KeyValuePair <string, object> (cea.valueToSet, valueInt), DisplayReturnMessage, DisplayErrorMessage)
                                                     );
                    }
                    else if (Double.TryParse(cea.valueToSet2, out valueDouble))
                    {
                        ThreadPool.QueueUserWorkItem(o =>
                                                     pubnub.SetUserState <string> (cea.channel, cea.channelGroup, new KeyValuePair <string, object> (cea.valueToSet, valueDouble), DisplayReturnMessage, DisplayErrorMessage)
                                                     );
                    }
                    else
                    {
                        ThreadPool.QueueUserWorkItem(o =>
                                                     pubnub.SetUserState <string> (cea.channel, cea.channelGroup, new KeyValuePair <string, object> (cea.valueToSet, cea.valueToSet2), DisplayReturnMessage, DisplayErrorMessage)
                                                     );
                    }
                }
                else if (cea.cds == CommonDialogStates.SetUserStateJson)
                {
                    string jsonUserState = "";
                    if (string.IsNullOrEmpty(cea.valueToSet2))
                    {
                        //jsonUserState = ;
                    }
                    else
                    {
                        jsonUserState = cea.valueToSet2;
                    }
                    ThreadPool.QueueUserWorkItem(o =>
                                                 pubnub.SetUserState <string> (cea.channel, cea.channelGroup, cea.valueToSet, jsonUserState, DisplayReturnMessage, DisplayErrorMessage)
                                                 );
                }
            } catch (Exception ex) {
                Display(ex.Message);
            } finally {
                CommonDialogFragment coroutine = sender as CommonDialogFragment;
                coroutine.SetValues -= HandleSetValues;
            }
        }
Beispiel #24
0
 public void AuthKey ()
 {
     var dialog = new CommonDialogFragment (CommonDialogStates.Auth, this);
     dialog.SetValues += HandleSetValues;
     dialog.Show (SupportFragmentManager, "dialog");
 }
Beispiel #25
0
 void HandleSetValues(object sender, EventArgs ea)
 {
     try {
         SetEventArgs cea = ea as SetEventArgs;
         if (cea.cds == CommonDialogStates.Auth)
         {
             Display("Setting Auth Key");
             pubnub.AuthenticationKey = cea.valueToSet;
             Display("Auth Key set");
         }
         else if (cea.cds == CommonDialogStates.ChangeUuid)
         {
             Display("Setting UUID");
             pubnub.ChangeUUID(cea.valueToSet);
             Display(string.Format("UUID set to {0}", pubnub.SessionUUID));
         }
         else if (cea.cds == CommonDialogStates.WhereNow)
         {
             Display("Running where now");
             pubnub.WhereNow <string> (cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage);
         }
         else if (cea.cds == CommonDialogStates.GetUserState)
         {
             Display("Running get user state");
             pubnub.GetUserState <string> (cea.channel, cea.valueToSet, DisplayReturnMessage, DisplayErrorMessage);
         }
         else if (cea.cds == CommonDialogStates.DeleteLocalUserState)
         {
             Display("Running delete local user state");
             string currentUserStateAfterDelete = pubnub.SetLocalUserState(cea.channel, cea.valueToSet, null);
             Display(string.Format("Current user state: {0}", currentUserStateAfterDelete));
         }
         else if (cea.cds == CommonDialogStates.PresenceHeartbeat)
         {
             Display("Setting presence heartbeat");
             //int check done in CommonDialogFragment
             pubnub.PresenceHeartbeat = int.Parse(cea.valueToSet);
             Display(string.Format("PresenceHeartbeat set to {0}", pubnub.PresenceHeartbeat));
         }
         else if (cea.cds == CommonDialogStates.PresenceHeartbeatInterval)
         {
             Display("Setting presence interval");
             //int check done in CommonDialogFragment
             pubnub.PresenceHeartbeatInterval = int.Parse(cea.valueToSet);
             Display(string.Format("PresenceHeartbeatInterval set to {0}", pubnub.PresenceHeartbeatInterval));
         }
         else if (cea.cds == CommonDialogStates.AddLocalUserState)
         {
             string currentState = pubnub.SetLocalUserState(cea.channel, cea.valueToSet, cea.valueToSet2);
             Display(string.Format("Current user state: {0}", currentState));
         }
         else if (cea.cds == CommonDialogStates.SetUserState)
         {
             string jsonUserState = "";
             if (string.IsNullOrEmpty(cea.valueToSet2))
             {
                 jsonUserState = pubnub.GetLocalUserState(cea.channel);
             }
             else
             {
                 jsonUserState = cea.valueToSet2;
             }
             pubnub.SetUserState <string> (cea.channel, cea.valueToSet, jsonUserState, DisplayReturnMessage, DisplayErrorMessage);
         }
     } catch (Exception ex) {
         Display(ex.Message);
     } finally {
         CommonDialogFragment coroutine = sender as CommonDialogFragment;
         coroutine.SetValues -= HandleSetValues;
     }
 }