dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Simple Socket server I can run on my Mac?

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    3

    Simple Socket server I can run on my Mac?

    Hi there, thanks for checking my post. I need to set up a project whereby a mobile (Nokia N96) can open a SWF and then control what is displaying on another SWF on my computer. I am planning to do this over a wireless network using a socket server.

    So far I have got my Flash Lite SWF to load a jpg from my mac using the loadMovie() method:

    loadMovie("http://192.168.1.3/~username/project/img.jpg", holder);

    What I need to do is to be able to get the phone to connect to an XML Socket server running on my Mac and also have a SWF running on my Mac's browser that is connected to the same socket server. The aim is that when a button is pressed on the mobile phone, the SWF that is running on my mac will update accordingly.

    I am an experienced Flash developer but I haven't worked with Flash Lite before and have only set up the flosc server which wont work with Flash Lite as it's AS3.

    If anyone can help me find a socket server I can run locally on my mac that will allow a flash lite app running on a mobile phone (on the same wifi network) to connect I would be really grateful.

    Thanks for any help in advance
    Hect

  2. #2
    Moderator
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    what version of Flash Lite are you testing on the N96?

    You will need to verify this, but there are certain versions of Flash Lite which did not support the XML socket connection. This may have been added in 3.0 or 3.1, but I dont think it is part of 2.x.
    aviarts.com - web development and flash development

  3. #3
    Junior Member
    Join Date
    Aug 2009
    Posts
    3
    hi hp3, thanks for your reply, the version of flashlite that is running is version 3, this supports XML Sockets.

    I've managed to connect to an xml socket server running on my mac:
    http://www.rshields.com/?q=node/91

    My problem now is, I can connect to the server when I run my Flash Lite application in Adobe Device Central but when I place the swf on my phone (Nokia N96) in the folder c:/data/others/trusted and run it through the gallery I can't connect to the server (the swf tries to connect but fails).

    I believe I have fulfilled all of the security requirements, (crossdomain.xml file in the root of my mac's sites folder) but I still can't get this to work!

    If anyone can help me sort this I would be really grateful, I only need this app to run on my local network as it's for an installation.


    My code is below
    Many thanks!
    Hect


    Code:
    var keyListener:Object = new Object();
    var holder:MovieClip = this.createEmptyMovieClip("holder", this.getNextHighestDepth());
    function setupSecurity(){
    	System.security.allowDomain("*");
    	System.security.allowInsecureDomain("*");
    	System.security.loadPolicyFile("http://192.168.1.3");
    }
    
    // Define the onKeyDown events to listen to
    keyListener.onKeyDown = function() {
    	//trace(text_txt);
    	attachMovie("square", "sq",1); 
    	trace(">");
        if (Key.getCode() == Key.ENTER) {
    		//this address won't connect when running on the phone
    		socket.connect("192.168.1.3", 6780);
            traceIt("connecting 192.168.1.3");
        }
        else if (Key.getCode() == ExtendedKey.SOFT1) {
            traceIt("Left softkey pressed");
        }
        else if (Key.getCode() == ExtendedKey.SOFT2) {
            traceIt("Right softkey pressed");
        }
        else if (Key.getCode() == Key.UP) {
           // loads an image to check that the ip address is correct
    		loadMovie("http://192.168.1.3/~username/project/img.jpg", holder);
        }
    	 else if (Key.getCode() == Key.DOWN) {
           // this works when running the app locally in adobe device central
    	   traceIt("connecting 127.0.0.1");
    		socket.connect("127.0.0.1", 6780);
        }else if (Key.getCode() == Key.LEFT){
    		traceIt("setting security");
    		setupSecurity();
    	}
    }
    
    
    var socket:XMLSocket = new XMLSocket();
    socket.onConnect = function (success) {
    	traceIt("onc");
       if (success){
    		traceIt("success");   
       }else{
    	   traceIt("fail");
       }
    }
    
    
    socket.onData = function(d){
    	traceIt("data:"+d.toString());
    }
    
    
    function traceIt(s:String){
    	text_txt.text += s+"\r";
    }
    
    // Enable the key listener
    Key.addListener(keyListener);
    setupSecurity();

  4. #4
    Moderator
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    Unfortunately, I dont have much experience with this type of issue, but I seem to recall something about publishing with network access vs. local access. Perhaps there is something you need to do here as well.
    aviarts.com - web development and flash development

  5. #5
    Junior Member
    Join Date
    Aug 2009
    Posts
    3
    thanks for yr response hp3, I have this working now, I just needed to set the socket server's ip in the config settings in terminal. yr right about the network access in publishing settings too

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center