Within my program, I'm simply using a callback method from my clientside in order to retrieve the value of a string from a function from within the server side (main.asc). However, it seems as if not only does this not perform but the server side (main.asc) isn't even being seen/"processed" at all due to the fact that none of the trace statements even appear (like methods as .onAppStart, etc.) in the output. Could anyone help me out here?
Client-Side:
Code:
package
{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.NetStatusEvent;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Camera;
import flash.media.Microphone;
import flash.media.Video;
import flash.net.Responder;
import fl.controls.Button;
import fl.controls.TextInput;
import flash.events.SyncEvent;
import flash.events.MouseEvent;
import flash.net.SharedObject;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import fl.controls.TextArea;
import flash.events.FocusEvent;
import fl.events.ComponentEvent;
import flash.net.ObjectEncoding;
public class CommunicationSuite extends Sprite
{
private var netOut:NetStream;
private var netIn:NetStream;
private var nc:NetConnection;
private var videoOut:Video;
private var videoIn:Video;
private var myStream:String;
private var clientStream:String;
private var goodConnection:Boolean;
private var mic:Microphone;
private var cam:Camera;
private var responder:Responder;
private var rtmpNow:String;
private var button:Button;
private var webSO:SharedObject;
private var textInput:TextInput;
private var webURL:String;
private var webRequest:URLRequest;
private var chatButton:Button;
private var textSO:SharedObject;
private var textArea:TextArea;
private var chatInput:TextInput;
private var chatName:TextInput;
private var catchKey:Boolean;
private var noName:Boolean;
public function CommunicationSuite()
{
NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
rtmpNow = "rtmp:/commSuite";
nc = new NetConnection;
nc.connect(rtmpNow);
nc.addEventListener (NetStatusEvent.NET_STATUS,getConnected);
nc.addEventListener (NetStatusEvent.NET_STATUS,getStream);
btnSite.addEventListener (MouseEvent.CLICK,showSite);
inputChat.addEventListener (ComponentEvent.ENTER,checkKey);
btnChat.label="Send Message";
btnChat.addEventListener (MouseEvent.CLICK,sendMsg);
inputName.text="<Enter Name>";
inputName.addEventListener (FocusEvent.FOCUS_IN,cleanName);
}
public function getConnected(e:NetStatusEvent)
{
goodConnection = e.info.code == "NetConnection.Connect.Success";
if(goodConnection)
{
webSO=SharedObject.getRemote("website",nc.uri,false);
webSO.connect (nc);
webSO.addEventListener (SyncEvent.SYNC,checkSite);
textSO=SharedObject.getRemote("test",nc.uri,false);
textSO.connect (nc);
textSO.addEventListener (SyncEvent.SYNC,checkChat);
}
else
{
trace("Connection Not Established");
}
}
public function checkSite(object:SyncEvent):void
{
for (var count:uint; count<object.changeList.length; count++)
{
switch (object.changeList[count].code)
{
case "clear" :
break;
case "success" :
trace (webSO.data.website);
break;
case "change" :
webRequest=new URLRequest(webSO.data.website);
navigateToURL (webRequest,"_blank");
break;
}
}
}
public function checkChat(object:SyncEvent):void
{
for (var count:uint; count<object.changeList.length; count++)
{
switch (object.changeList[count].code)
{
case "clear" :
break;
case "success" :
break;
case "change" :
areaChat.appendText (textSO.data.userText + "\n");
break;
}
}
}
private function cleanName (object:FocusEvent):void
{
inputName.text="";
}
private function sendMsg (e:MouseEvent):void
{
noName=(inputName.text=="<Enter Name>" || inputName.text=="");
if (noName)
{
textArea.appendText ("You must enter a name \n");
}
else
{
textSO.setProperty ("userText",inputName.text +": "+ inputChat.text);
areaChat.appendText (inputName.text +": "+ inputChat.text + "\n");
inputChat.text="";
}
}
private function checkKey (e:ComponentEvent):void
{
noName=(inputName.text=="<Enter Name>" || inputName.text=="");
if (noName)
{
textArea.appendText ("You must enter a name \n");
}
else
{
textSO.setProperty ("userText",inputName.text +": "+ inputChat.text);
areaChat.appendText (inputName.text +": "+ inputChat.text + "\n");
inputChat.text="";
}
}
private function showSite (evt:MouseEvent):void
{
webSO.setProperty ("website", "http://"+ inputSite.text);
}
private function getStream (e:NetStatusEvent):void
{
goodConnection=e.info.code == "NetConnection.Connect.Success";
trace(goodConnection);
if (goodConnection)
{
responder=new Responder(streamNow);
nc.call ("streamSelect",responder);
}
}
private function streamNow (streamSelect:String):void
{
cam=Camera.getCamera();
cam.setMode(640, 480,15);
cam.setQuality(0,85);
cam.setKeyFrameInterval(15);
mic = Microphone.getMicrophone();
mic.rate=22;
mic.setSilenceLevel(12,1000);
videoOut=new Video(134,134);
addChild(videoOut);
videoOut.x=38;
videoOut.y=53;
videoIn=new Video(134,134);
addChild(videoIn);
videoIn.x=204;
videoIn.y=51;
switch (streamSelect)
{
case "left" :
myStream="left";
clientStream="right";
break;
case "right" :
myStream="right";
clientStream="left";
break;
}
netOut=new NetStream(nc);
netOut.attachAudio (mic);
netOut.attachCamera (cam);
videoOut.attachCamera (cam);
netOut.publish (myStream, "live");
netIn=new NetStream(nc);
videoIn.attachNetStream (netIn);
netIn.play (clientStream);
}
}
}
Server-Side:
Code:
load("netservices.asc");
vidStreams=["right","left"];
application.onAppStart = function()
{
trace("The duce is out of the deck");
}
application.onConnect = function(currentClient)
{
if (vidStreams.length <= 0)
{
application.rejectConnection(currentClient);
}
currentClient.cliNow=vidStreams.pop();
application.acceptConnection(currentClient);
currentClient.streamSelect = function()
{
trace("Stream "+currentClient.cliNow+" used");
return currentClient.cliNow;
}
}
application.onDisconnect = function(currentClient)
{
vidStreams.push(currentClient.cliNow);
}