Hello Everyone,
I'm having an issue with setting up a test Chat client. I can login to the AFCS air app as the developer and I can login with my Flex sample. However, when I change my AdobeHSAuthenticator.authenticator.userName to Guest and set the password = null, I receive an "Error #1009: Cannot access a property or method of a null object reference." FlashDevelop is pointing to the sendMessage method and the clear method of the SimpleChatModel Object.
Any Ideas? Thanks in Advance
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" x="0" title="Simple Chat" width="400" height="400"
xmlns:rtc="AfcsNameSpace" creationComplete="init();">
<mx:Script>
<![CDATA[
import com.adobe.rtc.sharedModel.descriptors.ChatMessageDescriptor;
import com.adobe.rtc.session.ConnectSessionContainer;
import com.adobe.rtc.events.ChatEvent;
import com.adobe.rtc.sharedModel.SimpleChatModel;
import com.adobe.rtc.events.AuthenticationEvent;
import com.adobe.rtc.authentication.AdobeHSAuthenticator;
import com.adobe.rtc.events.SessionEvent;
import flash.ui.Keyboard;
import mx.controls.Alert;
import flash.events.*;
// this simple example just shows how this shared model can be made easily binable for MXML.
// See SimpleChatModel for details
[Bindable]
public var _auth:AdobeHSAuthenticator = new AdobeHSAuthenticator();
[Bindable]
public var simpleChatModel:SimpleChatModel;
[Bindable]
private var _cmd:ChatMessageDescriptor;
private function init():void
{
_auth.userName = "Guest";
_auth.password = null;
cSession.login();
_auth.addEventListener(AuthenticationEvent.AUTHENTICATION_FAILURE, onAuthenticationResponse);
_auth.addEventListener(AuthenticationEvent.AUTHENTICATION_SUCCESS, onAuthenticationResponse);
cSession.addEventListener(SessionEvent.SYNCHRONIZATION_CHANGE, onSessionEventResponse);
cSession.addEventListener(SessionEvent.ERROR, onSessionEventResponse);
}
public function onAuthenticationResponse(event:AuthenticationEvent):void {
if (event.type == AuthenticationEvent.AUTHENTICATION_SUCCESS) {
trace("Authentication Succeeded");
buildModel();
}
else if (event.type == AuthenticationEvent.AUTHENTICATION_FAILURE) {
Alert.show("Authentication Error : " + event.toString());
}
}
public function onSessionEventResponse(event:Event):void {
if (event.type == SessionEvent.SYNCHRONIZATION_CHANGE) {
if (cSession.isSynchronized) {
//Now we are connected and the Pods have synchronized themselves, so switch to main Screen
//Switch to Collaborative Pods i.e. ConnectSessionContainer
//vsMain.selectedIndex = 1;
}
else {
//We are disconnected now
cSession.roomURL = null;
//vsMain.selectedIndex = 0;
}
}
else if (event.type == SessionEvent.ERROR) {
var sError:SessionEvent = event as SessionEvent;
Alert.show(sError.error.name + " : " + sError.error.message);
}
}
private function buildModel():void
{
// Create the model: just calling the constructor won't create the collection node or pass the messages.
// Call subscribe and five it a shared ID while creating the model.
// The shared ID becomes the name of the collection node.
simpleChatModel = new SimpleChatModel(true);
simpleChatModel.sharedID = "simpleChatModel";
simpleChatModel.subscribe();
simpleChatModel.addEventListener(ChatEvent.HISTORY_CHANGE, onChatMsg);
}
private function submitChat(str:String):void
{
_cmd = new ChatMessageDescriptor();
_cmd.displayName = cSession.userManager.getUserDescriptor(cSession.userManager.myUserID).displayName;
trace(_cmd.displayName);
trace(str);
_cmd.msg = str;
simpleChatModel.sendMessage(_cmd);
chat_msg_input.text = "";
}
private function clearChat():void
{
chat_msg_area.text = "";
simpleChatModel.clear();
}
private function onChatMsg(evt:ChatEvent):void
{
if (evt.message != null && evt.message.msg != null && evt.message.displayName != null)
{
chat_msg_area.text += evt.message.displayName + ": " + evt.message.msg + "\r";
} else {
chat_msg_area.text = "";
}
}
]]>
</mx:Script>
<rtc:ConnectSessionContainer roomURL="https://connectnow.acrobat.com/trainone/myfirstroom" authenticator="{_auth}"
id="cSession"
width="100%"
height="100%"
autoLogin="false">
<mx:VBox width="100%" height="100%">
<mx:TextArea width="100%" height="100%" id="chat_msg_area" />
<mx:ControlBar >
<mx:TextInput width="100%" id="chat_msg_input" />
<mx:Button label="Submit Chat" click="{ submitChat(chat_msg_input.text) }" />
<mx:Button label="Clear Chat" click="clearChat()" />
</mx:ControlBar>
</mx:VBox>
</rtc:ConnectSessionContainer>
</mx:TitleWindow>
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
I modified your code and it works now. Your buildModel() method wasnt called and so the SimpleChatModel was always null. That was because our service was too fast :), and we were broadcasting the AuthenticationSuccess event even before you can catch it. It should work now.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" x="0" width="400" height="400"
xmlns:rtc="AfcsNameSpace" creationComplete="init(event);">
<mx:Script>
<![CDATA[
import com.adobe.rtc.authentication.AdobeHSAuthenticator;
import com.adobe.rtc.events.AuthenticationEvent;
import com.adobe.rtc.events.ChatEvent;
import com.adobe.rtc.events.SessionEvent;
import com.adobe.rtc.session.ConnectSessionContainer;
import com.adobe.rtc.sharedModel.SimpleChatModel;
import com.adobe.rtc.sharedModel.descriptors.ChatMessageDescriptor;
import flash.events.*;
import flash.ui.Keyboard;
import mx.controls.Alert;
// this simple example just shows how this shared model can be made easily binable for MXML.
// See SimpleChatModel for details
[Bindable]
public var _auth:AdobeHSAuthenticator = new AdobeHSAuthenticator();
[Bindable]
public var simpleChatModel:SimpleChatModel;
[Bindable]
private var _cmd:ChatMessageDescriptor;
protected function init(p_evt:Event):void
{
_auth.userName = "Guest";
_auth.password = null;
_auth.addEventListener(AuthenticationEvent.AUTHENTICATION_FAILURE, onAuthenticationResponse);
_auth.addEventListener(AuthenticationEvent.AUTHENTICATION_SUCCESS, onAuthenticationResponse);
cSession.addEventListener(SessionEvent.SYNCHRONIZATION_CHANGE, onSessionEventResponse);
cSession.addEventListener(SessionEvent.ERROR, onSessionEventResponse);
cSession.login();
}
public function onAuthenticationResponse(event:AuthenticationEvent):void {
if (event.type == AuthenticationEvent.AUTHENTICATION_SUCCESS) {
trace("Authentication Succeeded");
buildModel();
}
else if (event.type == AuthenticationEvent.AUTHENTICATION_FAILURE) {
Alert.show("Authentication Error : " + event.toString());
}
}
public function onSessionEventResponse(event:Event):void {
if (event.type == SessionEvent.SYNCHRONIZATION_CHANGE) {
if (cSession.isSynchronized) {
//Now we are connected and the Pods have synchronized themselves, so switch to main Screen
//Switch to Collaborative Pods i.e. ConnectSessionContainer
//vsMain.selectedIndex = 1;
}
else {
//We are disconnected now
cSession.roomURL = null;
//vsMain.selectedIndex = 0;
}
}
else if (event.type == SessionEvent.ERROR) {
var sError:SessionEvent = event as SessionEvent;
Alert.show(sError.error.name + " : " + sError.error.message);
}
}
private function buildModel():void
{
// Create the model: just calling the constructor won't create the collection node or pass the messages.
// Call subscribe and five it a shared ID while creating the model.
// The shared ID becomes the name of the collection node.
simpleChatModel = new SimpleChatModel(true);
simpleChatModel.sharedID = "simpleChatModel";
simpleChatModel.subscribe();
simpleChatModel.addEventListener(ChatEvent.HISTORY_CHANGE, onChatMsg);
}
private function submitChat(str:String):void
{
_cmd = new ChatMessageDescriptor();
_cmd.displayName = cSession.userManager.getUserDescriptor(cSession.userManager.myUserID).displayName;
trace(_cmd.displayName);
trace(str);
_cmd.msg = str;
simpleChatModel.sendMessage(_cmd);
chat_msg_input.text = "";
}
private function clearChat():void
{
chat_msg_area.text = "";
simpleChatModel.clear();
}
private function onChatMsg(evt:ChatEvent):void
{
if (evt.message != null && evt.message.msg != null && evt.message.displayName != null)
{
chat_msg_area.text += evt.message.displayName + ": " + evt.message.msg + "\r";
} else {
chat_msg_area.text = "";
}
}
]]>
</mx:Script>
<rtc:ConnectSessionContainer roomURL="https://connectnow.acrobat.com/trainone/myfirstroom" authenticator="{_auth}"
id="cSession"
width="100%"
height="100%"
autoLogin="false" >
<mx:VBox width="100%" height="100%">
<mx:TextArea width="100%" height="100%" id="chat_msg_area" />
<mx:ControlBar >
<mx:TextInput width="100%" id="chat_msg_input" />
<mx:Button label="Submit Chat" click="{ submitChat(chat_msg_input.text) }" />
<mx:Button label="Clear Chat" click="clearChat()" />
</mx:ControlBar>
</mx:VBox>
</rtc:ConnectSessionContainer>
</mx:Application>
Views
Replies
Total Likes
Hi,
I modified your code and it works now. Your buildModel() method wasnt called and so the SimpleChatModel was always null. That was because our service was too fast :), and we were broadcasting the AuthenticationSuccess event even before you can catch it. It should work now.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" x="0" width="400" height="400"
xmlns:rtc="AfcsNameSpace" creationComplete="init(event);">
<mx:Script>
<![CDATA[
import com.adobe.rtc.authentication.AdobeHSAuthenticator;
import com.adobe.rtc.events.AuthenticationEvent;
import com.adobe.rtc.events.ChatEvent;
import com.adobe.rtc.events.SessionEvent;
import com.adobe.rtc.session.ConnectSessionContainer;
import com.adobe.rtc.sharedModel.SimpleChatModel;
import com.adobe.rtc.sharedModel.descriptors.ChatMessageDescriptor;
import flash.events.*;
import flash.ui.Keyboard;
import mx.controls.Alert;
// this simple example just shows how this shared model can be made easily binable for MXML.
// See SimpleChatModel for details
[Bindable]
public var _auth:AdobeHSAuthenticator = new AdobeHSAuthenticator();
[Bindable]
public var simpleChatModel:SimpleChatModel;
[Bindable]
private var _cmd:ChatMessageDescriptor;
protected function init(p_evt:Event):void
{
_auth.userName = "Guest";
_auth.password = null;
_auth.addEventListener(AuthenticationEvent.AUTHENTICATION_FAILURE, onAuthenticationResponse);
_auth.addEventListener(AuthenticationEvent.AUTHENTICATION_SUCCESS, onAuthenticationResponse);
cSession.addEventListener(SessionEvent.SYNCHRONIZATION_CHANGE, onSessionEventResponse);
cSession.addEventListener(SessionEvent.ERROR, onSessionEventResponse);
cSession.login();
}
public function onAuthenticationResponse(event:AuthenticationEvent):void {
if (event.type == AuthenticationEvent.AUTHENTICATION_SUCCESS) {
trace("Authentication Succeeded");
buildModel();
}
else if (event.type == AuthenticationEvent.AUTHENTICATION_FAILURE) {
Alert.show("Authentication Error : " + event.toString());
}
}
public function onSessionEventResponse(event:Event):void {
if (event.type == SessionEvent.SYNCHRONIZATION_CHANGE) {
if (cSession.isSynchronized) {
//Now we are connected and the Pods have synchronized themselves, so switch to main Screen
//Switch to Collaborative Pods i.e. ConnectSessionContainer
//vsMain.selectedIndex = 1;
}
else {
//We are disconnected now
cSession.roomURL = null;
//vsMain.selectedIndex = 0;
}
}
else if (event.type == SessionEvent.ERROR) {
var sError:SessionEvent = event as SessionEvent;
Alert.show(sError.error.name + " : " + sError.error.message);
}
}
private function buildModel():void
{
// Create the model: just calling the constructor won't create the collection node or pass the messages.
// Call subscribe and five it a shared ID while creating the model.
// The shared ID becomes the name of the collection node.
simpleChatModel = new SimpleChatModel(true);
simpleChatModel.sharedID = "simpleChatModel";
simpleChatModel.subscribe();
simpleChatModel.addEventListener(ChatEvent.HISTORY_CHANGE, onChatMsg);
}
private function submitChat(str:String):void
{
_cmd = new ChatMessageDescriptor();
_cmd.displayName = cSession.userManager.getUserDescriptor(cSession.userManager.myUserID).displayName;
trace(_cmd.displayName);
trace(str);
_cmd.msg = str;
simpleChatModel.sendMessage(_cmd);
chat_msg_input.text = "";
}
private function clearChat():void
{
chat_msg_area.text = "";
simpleChatModel.clear();
}
private function onChatMsg(evt:ChatEvent):void
{
if (evt.message != null && evt.message.msg != null && evt.message.displayName != null)
{
chat_msg_area.text += evt.message.displayName + ": " + evt.message.msg + "\r";
} else {
chat_msg_area.text = "";
}
}
]]>
</mx:Script>
<rtc:ConnectSessionContainer roomURL="https://connectnow.acrobat.com/trainone/myfirstroom" authenticator="{_auth}"
id="cSession"
width="100%"
height="100%"
autoLogin="false" >
<mx:VBox width="100%" height="100%">
<mx:TextArea width="100%" height="100%" id="chat_msg_area" />
<mx:ControlBar >
<mx:TextInput width="100%" id="chat_msg_input" />
<mx:Button label="Submit Chat" click="{ submitChat(chat_msg_input.text) }" />
<mx:Button label="Clear Chat" click="clearChat()" />
</mx:ControlBar>
</mx:VBox>
</rtc:ConnectSessionContainer>
</mx:Application>
Views
Replies
Total Likes
Hi,
I figured out your issue. You need to call the buildModel function inside the handler for SysnchronizationChange, which in your case is onSessionEventResponse. You are doing inside the handler of Authentication success , but we don't throw that event outside. So, your handler will not get called and hence, buildModel function for creating SipleChatModel doesn’t get executed.
Hope this helps
Thanks
Hironmay Basu
Thanks Everyone,
I've been struggling with this for 3 days, just needed to move my buildModel() after the listeners.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies