Exemple #1
0
 void HandleGrantPerms(object sender, EventArgs ea)
 {
     try {
         GrantEventArgs cea = ea as GrantEventArgs;
         if (cea.cds == CommonDialogStates.Grant)
         {
             Display("Running Subscribe Grant");
             ThreadPool.QueueUserWorkItem(o =>
                                          pubnub.Grant()
                                          .Channels(new [] { cea.channel })
                                          .AuthKeys(new [] { cea.authKey })
                                          .Read(cea.valToSet2)
                                          .Write(cea.valToSet1)
                                          .TTL(cea.ttl)
                                          .Async(new DemoGrantResult(Display))
                                          );
         }
         else if (cea.cds == CommonDialogStates.HereNow)
         {
             Display("Running HereNow");
             ThreadPool.QueueUserWorkItem(o =>
                                          pubnub.HereNow()
                                          .Channels(new [] { cea.channel })
                                          .IncludeUUIDs(cea.valToSet2)
                                          .IncludeState(cea.valToSet1)
                                          .Async(new DemoHereNowResult(Display))
                                          );
         }
         else if (cea.cds == CommonDialogStates.GlobalHereNow)
         {
             Display("Running GlobalHereNow");
             ThreadPool.QueueUserWorkItem(o =>
                                          pubnub.HereNow().IncludeUUIDs(cea.valToSet2)
                                          .IncludeState(cea.valToSet1)
                                          .Async(new DemoHereNowResult(Display))
                                          );
         }
         else if (cea.cds == CommonDialogStates.Publish)
         {
             Display("Running Publish");
             string[] channels = cea.channel.Split(',');
             string   mess     = cea.message;
             foreach (string channelToCall in channels)
             {
                 ThreadPool.QueueUserWorkItem(o =>
                                              pubnub.Publish()
                                              .Channel(channelToCall.Trim())
                                              .Message(mess)
                                              .ShouldStore(cea.valToSet2)
                                              .Async(new DemoPublishResult(Display))
                                              );
             }
         }
     } catch (Exception ex) {
         Display(ex.Message);
     } finally {
         GrantDialogFragment coroutine = sender as GrantDialogFragment;
         coroutine.GrantPerms -= HandleGrantPerms;
     }
 }
Exemple #2
0
 void HandleGrantPerms(object sender, EventArgs ea)
 {
     try {
         GrantEventArgs cea = ea as GrantEventArgs;
         if (cea.cds == CommonDialogStates.Grant)
         {
             if (cea.isPresence)
             {
                 Display("Running Presence Grant");
                 pubnub.GrantPresenceAccess <string> (channel, cea.valToSet2, cea.valToSet1, cea.ttl, DisplayReturnMessage, DisplayErrorMessage);
             }
             else
             {
                 Display("Running Subscribe Grant");
                 pubnub.GrantAccess <string> (channel, cea.valToSet2, cea.valToSet1, cea.ttl, DisplayReturnMessage, DisplayErrorMessage);
             }
         }
         else if (cea.cds == CommonDialogStates.HereNow)
         {
             pubnub.HereNow <string> (cea.channel, cea.valToSet2, cea.valToSet1, DisplayReturnMessage, DisplayErrorMessage);
         }
         else if (cea.cds == CommonDialogStates.GlobalHereNow)
         {
             pubnub.GlobalHereNow <string> (cea.valToSet2, cea.valToSet1, DisplayReturnMessage, DisplayErrorMessage);
         }
     } catch (Exception ex) {
         Display(ex.Message);
     } finally {
         GrantDialogFragment coroutine = sender as GrantDialogFragment;
         coroutine.GrantPerms -= HandleGrantPerms;
     }
 }
 public void FireEvent(int iTtl, bool canRead, bool canWrite, bool isPresence){
     if(GrantPerms != null)
     {
         GrantEventArgs cea = new GrantEventArgs ();
         cea.canRead = canRead;
         cea.canWrite = canWrite;
         cea.ttl = iTtl;
         cea.isPresence = isPresence;
         GrantPerms(this, cea);
     }
 }
 public void HereNowFireEvent(string channel, bool showUUID, bool includeUserState)
 {
     if (GrantPerms != null)
     {
         GrantEventArgs cea = new GrantEventArgs();
         cea.valToSet2 = showUUID;
         cea.valToSet1 = includeUserState;
         cea.cds       = cds;
         cea.channel   = channel;
         GrantPerms(this, cea);
     }
 }
 public void PublishFireEvent(string channel, string message, bool showUUID)
 {
     if (GrantPerms != null)
     {
         GrantEventArgs cea = new GrantEventArgs();
         cea.valToSet2 = showUUID;
         cea.cds       = cds;
         cea.channel   = channel;
         cea.message   = message;
         GrantPerms(this, cea);
     }
 }
Exemple #6
0
 void HandleGrantPerms(object sender, EventArgs ea)
 {
     try {
         GrantEventArgs cea = ea as GrantEventArgs;
         if (cea.cds == CommonDialogStates.Grant)
         {
             if (cea.isPresence)
             {
                 Display("Running Presence Grant");
                 ThreadPool.QueueUserWorkItem(o =>
                                              pubnub.GrantPresenceAccess <string> (channel, cea.channel, cea.valToSet2, cea.valToSet1, cea.ttl, DisplayReturnMessage, DisplayErrorMessage)
                                              );
             }
             else
             {
                 Display("Running Subscribe Grant");
                 ThreadPool.QueueUserWorkItem(o =>
                                              pubnub.GrantAccess <string> (channel, cea.channel, cea.valToSet2, cea.valToSet1, cea.ttl, DisplayReturnMessage, DisplayErrorMessage)
                                              );
             }
         }
         else if (cea.cds == CommonDialogStates.HereNow)
         {
             ThreadPool.QueueUserWorkItem(o =>
                                          pubnub.HereNow <string> (cea.channel, cea.valToSet2, cea.valToSet1, DisplayReturnMessage, DisplayErrorMessage)
                                          );
         }
         else if (cea.cds == CommonDialogStates.GlobalHereNow)
         {
             ThreadPool.QueueUserWorkItem(o =>
                                          pubnub.GlobalHereNow <string> (cea.valToSet2, cea.valToSet1, DisplayReturnMessage, DisplayErrorMessage)
                                          );
         }
         else if (cea.cds == CommonDialogStates.Publish)
         {
             Display("Running Publish");
             string[] channels = cea.channel.Split(',');
             string   mess     = cea.message;
             foreach (string channelToCall in channels)
             {
                 ThreadPool.QueueUserWorkItem(o =>
                                              pubnub.Publish <string> (channelToCall.Trim(), mess, cea.valToSet2,
                                                                       DisplayReturnMessage, DisplayErrorMessage)
                                              );
             }
         }
     } catch (Exception ex) {
         Display(ex.Message);
     } finally {
         GrantDialogFragment coroutine = sender as GrantDialogFragment;
         coroutine.GrantPerms -= HandleGrantPerms;
     }
 }
 public void FireEvent(int iTtl, bool canRead, bool canWrite, bool isPresence, string channel){
     if(GrantPerms != null)
     {
         GrantEventArgs cea = new GrantEventArgs ();
         cea.valToSet2 = canRead;
         cea.valToSet1 = canWrite;
         cea.ttl = iTtl;
         cea.isPresence = isPresence;
         cea.cds = cds;
         cea.channel = channel;
         GrantPerms(this, cea);
     }
 }
Exemple #8
0
 public void FireEvent(int iTtl, bool canRead, bool canWrite, bool isPresence, string channel)
 {
     if (GrantPerms != null)
     {
         GrantEventArgs cea = new GrantEventArgs();
         cea.valToSet2  = canRead;
         cea.valToSet1  = canWrite;
         cea.ttl        = iTtl;
         cea.isPresence = isPresence;
         cea.cds        = cds;
         cea.channel    = channel;
         GrantPerms(this, cea);
     }
 }
 public void HereNowFireEvent (string channel, bool showUUID, bool includeUserState)
 {
     if (GrantPerms != null) {
         GrantEventArgs cea = new GrantEventArgs ();
         cea.valToSet2 = showUUID;
         cea.valToSet1 = includeUserState;
         cea.cds = cds;
         cea.channel = channel;
         GrantPerms (this, cea);
     }
 }
 public void PublishFireEvent (string channel, string message, bool showUUID)
 {
     if (GrantPerms != null) {
         GrantEventArgs cea = new GrantEventArgs ();
         cea.valToSet2 = showUUID;
         cea.cds = cds;
         cea.channel = channel;
         cea.message = message;
         GrantPerms (this, cea);
     }
 }