6 Replies Latest reply on May 17, 2010 4:34 AM by BhaskerChari

    How to get client computer name or IP?

    Flex-Issac Level 1
      Hi all,

      Any Class or method to get the client computer name or IP? And the type of browser and version?

      Thanks
      orz
        • 2. Re: How to get client computer name or IP?
          Flex-Issac Level 1
          Thanks Ratsnackbar,

          I found Capabilities class, but it only keep OS version and other multimedia information. I haven't computer name or IP information. And I am using Flex 2 to be development.

          • 3. Re: How to get client computer name or IP?
            ntsiii Level 3
            You will need to get this from javascript functions via ExternalInterface
            Traqcy
            • 4. Re: How to get client computer name or IP?
              Ratsnackbar Level 2
              Yeah now that I have read through the whole Class I see your point. JavaScript is going to be the most likely answer. Depending on what you need it for though there are a host of other possibilities.

              If you are using ColdFusion there is another possible solution. I had one intranet App which would read the request and verify the IP was in a list of Allowed addresses before access to the SWF Files HTML Wrapper was granted.

              I had set up the DHCP server to use (or at least mimic) BootP so every Users System would always get the same IP address based on their MAC address. This made it possible to use the IP addresses as part of the security for the application.

              In that environment I had pretty much control of everything so it was easier to put together. Each users IP address was assigned to a username and password for that user in the database. Because I was also logging all of the detail of the request to a Database I was then able to use that information inside of Flex as RemoteObjects. This is a very round about way of doing it but it is certainly possible. I assume you can do the same with PHP or ASP but compared to CF they Blow Chunks. ;D Java and Ruby can do the same and don't blow chunks. It's just faster and easier in CF.

              The point is that if you are communicating with a server side language in any way you do not have to get all of the information from Client Side Scripting. It's available in the HTML Request so just use what is already there and send it back to Flex at what ever time best.

              P.S. Why do I keep hitting Control S every time I write a post?
              • 5. Re: How to get client computer name or IP?
                snkd Level 1

                This solution is for SBI(Spring BlazeDS Integraton) users only...

                I think it is better you get computer name from your back-end(Server side script)...

                If you use java Spring you can use following code segment.Actually it's work for me in spring.

                 

                FlexContext.getHttpRequest().getLocalName()

                 

                I am blogging @

                http://sankadil.blogspot.com/

                http://www.codexamples.blogspot.com/

                 

                in FlexContext.getHttpRequest() code segment what we did is get httprequest and then get the computer name from it.That is the way of proccesing client request in spring.

                thnx

                • 6. Re: How to get client computer name or IP?
                  BhaskerChari Level 4

                  Hi,

                   

                  You can use the below javascript function to get the browser type. Include this function in the html wrapper file in which your application is embedded and by using the ExternalInterface API call this function from Flex...the function will return you the browser type.

                   

                  function get browserType()
                  {


                  var nVer = navigator.appVersion;
                  var nAgt = navigator.userAgent;
                  var browserName  = navigator.appName;
                  var fullVersion  = ''+parseFloat(navigator.appVersion);
                  var majorVersion = parseInt(navigator.appVersion,10);
                  var nameOffset,verOffset,ix;

                  // In MSIE, the true version is after "MSIE" in userAgent
                  if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
                  browserName = "Microsoft Internet Explorer";
                  fullVersion = nAgt.substring(verOffset+5);
                  }
                  // In Opera, the true version is after "Opera"
                  else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
                  browserName = "Opera";
                  fullVersion = nAgt.substring(verOffset+6);
                  }
                  // In Chrome, the true version is after "Chrome"
                  else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
                  browserName = "Chrome";
                  fullVersion = nAgt.substring(verOffset+7);
                  }
                  // In Safari, the true version is after "Safari"
                  else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
                  browserName = "Safari";
                  fullVersion = nAgt.substring(verOffset+7);
                  }
                  // In Firefox, the true version is after "Firefox"
                  else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
                  browserName = "Firefox";
                  fullVersion = nAgt.substring(verOffset+8);
                  }
                  // In most other browsers, "name/version" is at the end of userAgent
                  else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) )
                  {
                  browserName = nAgt.substring(nameOffset,verOffset);
                  fullVersion = nAgt.substring(verOffset+1);
                  if (browserName.toLowerCase()==browserName.toUpperCase()) {
                    browserName = navigator.appName;
                  }
                  }
                  // trim the fullVersion string at semicolon/space if present
                  if ((ix=fullVersion.indexOf(";"))!=-1) fullVersion=fullVersion.substring(0,ix);
                  if ((ix=fullVersion.indexOf(" "))!=-1) fullVersion=fullVersion.substring(0,ix);

                  majorVersion = parseInt(''+fullVersion,10);
                  if (isNaN(majorVersion)) {
                  fullVersion  = ''+parseFloat(navigator.appVersion);
                  majorVersion = parseInt(navigator.appVersion,10);
                  }

                  return browserName + fullVersion;


                  }

                   

                   

                  Thanks,

                  Bhasker Chari