3 Replies Latest reply on Mar 15, 2011 7:15 PM by as4more

    Can Cirrus provide esentially a UUID or UDID?

    as4more Level 1

      I wondered if each client can request and ultimately get a reusable Unique User ID UUID or UDID (Stored via MobileApplication PresistanceManager or Preferences)

      What is recommend otherwise? Cause I'm contimplating various techniques for MobileApplications in Buritto and a bit lost so I thought I'd ask about a solution here, thanks.

       

         James

        • 1. Re: Can Cirrus provide esentially a UUID or UDID?
          Michael Thornburgh Adobe Employee

          not exactly.

           

          however, several properties of an RTMFP NetConnection are cryptographically pseudorandom and are globally unique and never re-used.  your peerID (NetConnection.nearID) is one such thing.  however, others can see your peerID by passive observation of network traffic.  NetConnection.nearNonce and .farNonce are also cryptographically pseudorandom, but are only known to your application and the server.

           

          depending on your needs, your peerID or one of the nonces could be retained in a local shared object as a globally unique pseudorandom value.

          • 2. Re: Can Cirrus provide esentially a UUID or UDID?
            as4more Level 1

            Cool and great to know Thanks!

             

            I've done this for now...

            package mypackage.mobile
            {
                public class DeviceID
                {
                    import flash.net.SharedObject;
                   
                    import mx.utils.UIDUtil;
                    import masterdomain.md5.MD5;
                   
                    private static var instance:DeviceID;
                   
                    private var devId:String;
                    private var sharedStore:SharedObject;
                   
                    public function DeviceID(enforcer:SingletonEnforcer) {
                        if (enforcer == null) {
                            throw new Error ("DeviceID is a singleton class, use getInstance() instead or id() directly");           
                        }
                    }
                   
                    public static function getInstance():DeviceID {
                        if(instance == null) {
                            instance = new DeviceID(new SingletonEnforcer);
                        }
                        return instance;
                    }
                   
                    public function id(hashed:Boolean = false):String {
                        if(devId == null) {
                            if(instance == null) {
                                instance = new DeviceID(new SingletonEnforcer());
                            }
                            sharedStore = SharedObject.getLocal("deviceID");
                            if(sharedStore == null) {
                                throw new Error ("Failed to Create SharedObject");           
                            }
                            if(sharedStore.data.deviceID != null) {
                                devId = sharedStore.data.deviceID;
                            }
                            else {
                                sharedStore.data.deviceID = devId = UIDUtil.createUID();
                                sharedStore.flush();
                            }
                        }
                        if(hashed == true) {
                            return MD5.hash(devId);
                        }
                       
                        return devId;
                    }
                }
            }

             

            class SingletonEnforcer {}

             

             

            one can skip the hash part abviously.

            Static-ness forces one to cal id() from the getInstance() or it fails. You'd have to make static all properties and then you can use id directly from the Class like getInstance()

            • 3. Re: Can Cirrus provide esentially a UUID or UDID?
              as4more Level 1

              Right well while trying pretty much in vain to get the Remote IP address I build this from pieces and descided at least in AIR the HardwareAdress should be the only really unique hardware or UDID needed...

              so with the class below you can get that with this for instance.

                 var np:NetworkProbe = NetworkProbe.getInstance();
                 np.probe();
                 np.networkArray[0].hardwareAdress;

              Then you could store it in the provious StoreObject too I suppose.

               

              package myfruitypackage.network
              {
                  public class NetworkProbe
                  {
                      import flash.net.InterfaceAddress;
                      import flash.net.NetworkInfo;
                      import flash.net.NetworkInterface;

               

                      private static var instance:NetworkProbe;

               

                      public var networkArray:Array = new Array();

               

                      private var networkInfo:NetworkInfo = NetworkInfo.networkInfo;
                      private var networkInterfaces:Vector.<NetworkInterface> = networkInfo.findInterfaces();

               

                      public function NetworkProbe(enforcer:SingletonEnforcer) {
                          if (enforcer == null) {
                              throw new Error ("DeviceID is a singleton class, use getInstance() instead or id() directly");           
                          }
                      }
                     
                      public static function getInstance():NetworkProbe {
                          if(instance == null) {
                              instance = new NetworkProbe(new SingletonEnforcer);
                          }
                          return instance;
                      }

               

                      public function probe():Array {
                          var ni:NetworkInterface;
                          var netObj:Object;
                          networkArray = new Array();
                          for each (ni in networkInterfaces) {
                              netObj = new Object();
                              trace("NetworkProbe probing:" + ni.name + " active:" + ni.active + " adress:" + ni.addresses[0].address + " ipVersion:" + ni.addresses[0].ipVersion + " hardwareAdress:" + ni.hardwareAddress);
                              netObj.name = ni.name;
                              netObj.active = ni.active;
                              netObj.address = ni.addresses[0].address;
                              netObj.ipVersion = ni.addresses[0].ipVersion;
                              netObj.hardwareAddress = ni.hardwareAddress;
                              networkArray.push(netObj);
                          }
                         
                          return networkArray;
                      }

               

                  }
              }

               

              class SingletonEnforcer {}