• Virtual Classroom
    2 replies, posted
I'm working on this virtual classroom using actionscript 3. It uses two webcam feeds, one from the client, another from one of the other clients connected to the server. It also has a sidebar that holds all the usernames of those currently connected to it. For the moment, it's rather crude, and mainly a 'proof of concept', but I'm running into several issues. For the server, I set the ip address to the address of my server on my local network. I have this small problem - whenever a new user connects to the server, all the previous users' tags are replaced by a 'false' tag. Additionally, for some reason, I can't seem to connect clients from different ip addresses to my server at the current network I'm on - only localhost connections will be accepted. I'm using flash media server for this. Can anyone help? Here's the code for the client: import fl.data.DataProvider; trace(nick); var cam = Camera.getCamera(); var mic = Microphone.getMicrophone(); var video = new Video(); cam.setMode(320, 240, 15, true); cam.setQuality(0, 100); video.y = 480; addChild(video); video.attachCamera(cam); var server_addr = "rtmp://10.150.43.201:80/lzlive"; var oaddr = "rtmp://10.150.43.201/lzlive/" var nc = new NetConnection(); nc.client = this; nc.connect(server_addr, nick); nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); nc.client.getClientList = nc_getClientList; nc.client.updateClientList = nc_updateClientList; var ns:NetStream; function publish(){ vplayer.source = "rtmp://10.150.43.201/lzlive/" + nick; } function netStatusHandler(event:NetStatusEvent):void { trace(event.info.code); if (event.info.code == "NetConnection.Connect.Success") { ns = new NetStream(nc); ns.addEventListener(NetStatusEvent.NET_STATUS, publishHandler); ns.attachCamera(cam); ns.attachAudio(mic); ns.bufferTime = 0; ns.publish(nick); function publishHandler(event:NetStatusEvent):void { trace(event.info.code); if(event.info.code == "NetStream.Publish.Start") { setTimeout(publish, 3000); //vplayer.source = "rtmp://127.0.0.1/live/" + nick; } } } } userlist.addEventListener(Event.CHANGE, updateUserList); function updateUserList(event:Event) { var selected_nick = event.target.selectedItem.label; vplayer.source = oaddr + selected_nick; } var clients = {}; function nc_getClientList(clients:Object) { var l = []; for(var i in clients) l.push({label: clients[i]}); userlist.dataProvider = new DataProvider(l); } function nc_updateClientList(mode:String, n:String):void { if(n == nick) return; if(mode == "add") clients[n] = n; else if(mode == "remove") delete clients[n]; var l = []; for(var i in clients) l.push({label: i}); userlist.dataProvider = new DataProvider(l); }
Use code tags.
Port forwarding?
Sorry, you need to Log In to post a reply to this thread.