Expand my Community achievements bar.

simple stuff not working - simple client, basic chat

Avatar

Level 1

Hi,

I'm obviously missing the point here and apologies and I've now spent about 24h on this but:

In my app,lots of hardcoding but heres the relevant chunks:

// this bit is going to fetch the authToken string... thats all it does and seems to be fine

<mx:RemoteObject id="CTYCHAT"
    endpoint="https://www.xxxxxxxxx.com/amfphp/gateway.php"
    source="cty.chats" destination="amfphp" showBusyCursor="true">
<mx:method name="getchat" result="resultHandler(event)" fault="faultHandler(event)">
</mx:method>
</mx:RemoteObject>

// when the user has logged to the main application (not the chat),  this gets called, the idea being they have a screen name and are accessing a room as a guest only. The room will already exist. It may or may not have a host in it. Does a host have to exist before an anon guest can enter?

Certainly for my testing the room is live and hosted by owner available on https://na2.connectnow.acrobat.com/kevinyeandel/melksham.

I can go into my room using this URL. the room is fine. Typing in here never appears on the clients - even if I can get in from the clients its as if there are separate rooms with the same name that don't know about each other.

public function begin_chatting_enable(rm:String,usr:String):void 
{
       roomURL = "https://connectnow.acrobat.com/kevinyeandel/melksham";// [Bindable]
       CTYCHAT.getOperation('getchat').send(rm,usr);    // handler has the result, room and user passed in, resultHandler will take it from here, "melksham" and "frank" for example
}

private function resultHandler(evt:ResultEvent):void
{
          authToken = evt.message.body.toString(); // double and tripple checked - looks like a token generated from the guesid and room id.
          buildModel();  // Error: Error - insufficient permissions to create a new CollectionNode. You must be an OWNER of the room to add new multi-user features to it. Log in with developer credentials in order to do so.
}

<rtc:AdobeHSAuthenticator
        id="auth" authenticationKey="{authToken}"  />

where

[Bindable]
    private var authToken:String;

is a valid string completed by the resulthandler function

<rtc:ConnectSessionContainer roomURL="http://connectnow.acrobat.com/kevinyeandel/melksham" 
        id="cSession" authenticator="{auth}" width="300" height="478">
            <mx:VBox id="chatBox" height="478" width="300" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                <mx:TextArea width="307" height="392" id="chat_mesg_area" backgroundColor="#B3DEF9"/>
                <mx:TextInput width="300" id="chat_mesg_input" height="28"/>
                <mx:HBox>
                    <mx:Button label="Submit Chat" click="submitChat(chat_mesg_input.text)"/>
                    <mx:Button label="Clear Chat" click="clearChat()"/>
                </mx:HBox>                               
            </mx:VBox>
    </rtc:ConnectSessionContainer>

protected function buildModel():void   // often getting an authentication failure in here

//Error: Error - insufficient permissions to create a new CollectionNode. You must be an OWNER of the room to add new multi-user features to it. Log in with developer credentials in order to do so.

// well, when I got the authToken from the remote server it was obtained because my code logged in.
            {
                chatModel = new SimpleChatModel();
                chatModel.sharedID = authToken;
                chatModel.subscribe();
                chatModel.addEventListener(ChatEvent.HISTORY_CHANGE, onChatMsg);
                this.addEventListener(KeyboardEvent.KEY_UP, onKeyStroke);
            }

This file is called by the amfphp class - it's in the httpget url and called letmein.php

<?php
  require_once("/var/www/html/secret.php");
  require_once("afcs.php");
  $title = "AFCS External Authentication Sample";

  $room = $_GET["room"];
  $host  = "http://connectnow.acrobat.com";
  $accountURL = "{$host}/{$account}";
  $roomURL = "{$accountURL}/{$room}";

  session_start();

   $user = $_GET["user"];
   $role = $_GET["role"];
   $am = new AFCSAccount($accountURL);
   $am->login($devuser, $devpass);   /// so here I am using my dev account
   $session = $am->getSession($room);

   $_SESSION["XSESSION"] = $session;   // do I need this? what is it?

   $token = $session->getAuthenticationToken($secret, $user, $user, $role);

   $f=fopen("/tmp/letmein.txt","w+"); // proof the details are being received and used to generate the key
   fwrite ($f,"user =$user, \r\nRoom=$room, \r\nrole=$role,  \r\naccountUrl=$accountURL, \r\nhost=$host\r\n roomURL=$roomURL");
   fclose($f);
   print $token;
?>

Heres the amfphp code - also writes debug to file - proof the parameters are being received in the /tmp files

// called from RemoteObject CTYCHAT

<?php

class chats
{
   public function __construct()
   {
      $role=5;// value hardcoded below anyway
   }

   function getchat($screen_name,$room)
   {
      $f=fopen("/tmp/chat2.txt","w+"); // debug galore
      fwrite ($f,"Scr = $screen_name, Room =$room");  // correct
      $ch = curl_init();
      curl_setopt($ch,CURLOPT_URL,"http://localhost/amfphp/services/afcs/letmein.php?user=$screen_name&role=5&room=$room");
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $p= curl_exec ($ch);
      curl_close ($ch);

      fwrite($f,"Line= " .$p);  // looks like a very valid long string, checks out in amfphp browser
      fclose($f);
      return $p;
   }
}
?>

Obviously doing something wrong here, I firstly assume I can take the basic chat example and build it into a standard application by only moving the authentication to server-side which gives back an authToken string. If I am wrong then please tell me!

Next, is there a tool to decode an authToken string to find out whats going on in there?

Thanks in advance (and for at least reading this far).

Kevin

6 Replies

Avatar

Employee

Hey Kevin,

Not sure I understand exactly what the question is. What are you trying to do with the PHP endpoint? Are you trying to expose chat content to both a PHP based app as well as a Flex based application?

You might have figured it out at this point, but I thought I'd check.

=Ryan

ryan@adobe.com

Avatar

Level 1

Hi Ryan

Pretty much perfect timing. Put this in a holding pattern since posting but need to implement by end of next week.

>Are you trying to expose chat content to both a PHP based app as well as a Flex based application?

I think your question to me is making me answer, in part, my own questions.

Basically, I need the room to be "hosted" by a "non-human" - a "robot". The robot could be a flex app from a desktop but ideally server based/php/other. The robot is more of a listener than a speaker.

The background to this is:

1. User logs in to browser, this assigns them to a default room. If the room does not already exist the server creates the room - that room is then essentially permanent/subject to deletion (if not used over set period). The human user that caused the room to be created is never the host (2 below). When the room appears the host (a dumb bot) is already there to "welcome" them.

Other users can be assigned to that room. All members can chat to each other.

2. The creation of the room is done on the server via php - seems to work ok.

Out of scope but for completion, the action of creating the room also creates the "bot" (mentioned), the bot is then (or should be) the room host - it's basically a sniffer connected to a full text index and taxonomy engine.

Bot's job is to look for the mention of certain words, e.g. the name of a band, it then looks in other existing rooms then do stuff with the data.

You could draw vague parallels with twitter but it's more complex. I can tell you more offline if it is of interest.

Don't want to take up too much of your time and will revisit code this week (might be stuff all fits together after this break from it), but if you have any ideas/suggestions they will be very much appreciated.

Many thanks in advance.

Kevin

Avatar

Employee

Currently we don't have a way to write server-side bots (but we have a few ideas just in need of implementations).

We are trying to get some specs together in the next few weeks and get them validated by the forum.

If all goes well we should have an implementation in a few months (long time, but we are pretty busy with a bunch of other stuff)

In the mean time your only option is a client-side bot.

Avatar

Level 1

hello,

Did Adobe ever do the server-side bots?

8 months later I'm just getting round to solving this task!

Thanks

Kevin

Avatar

Level 1

Wow, I was reading your post and so am watching for an answer too, regarding the Robot hosting.

I have a question up regarding putting in a flashersize chat room with SWF.Just wanted to make contact and start a possible Dreamweaver forum group as there are none in my area.

Lake Forest California (southern CA)

bellamarie_cullen@live.com

I am doing a social networking type site from scratch, i am moving from ning.com and doing my own thing

Thanks and if interested email me.

Luanne (user name here is bellamariecullen)

Avatar

Former Community Member

Well, yes indeed, we now do support server-side bots. Get the SDK from

https://afcs.acrobat.com and check out the Developer Guide - there's a

whole section on the server-to-server APIs. They're still new, so there may

be some rough edges, but we'd love your feedback!

thanks

nigel