Is there a way that I'm missing in the api, or some other way to check for the existance of a single room before calling
AFCSAccount createRoom? I see that there's a getRoomInfo method but that seems to only apply to rooms that are active (well at least I get nothing back for inactive rooms, I could be doing it wrong). I also see there is a listRooms method but when I have 10,000 rooms that's going to be a pretty wasteful call.
So I'm looking for a way to check to see if a single room exists before I call createRoom. Any advice would be appreciated.
Thanks,
Eric
Solved! Go to Solution.
Views
Replies
Total Likes
Currently there is no way to check for the existence of a room (actually there is a way, but is not exposed).
But considering that no matter what you do it will cost you one HTTP request anyway, just always create the room and catch the error (the HTTP request will return an error 403)
Views
Replies
Total Likes
Currently there is no way to check for the existence of a room (actually there is a way, but is not exposed).
But considering that no matter what you do it will cost you one HTTP request anyway, just always create the room and catch the error (the HTTP request will return an error 403)
Views
Replies
Total Likes
Thanks Raff, worked like a charm.
Views
Replies
Total Likes
Hi esteimle
I am now in a similar situation to yourself, and getting an error when someone tries to log in to a room that already exists. I haven't quite got my head round where the try/catch code should go in relation to the Createroom code - would you mind sharing how you did it please?
This is a snippet of my code:
$room = strtolower($user);
$am = new AFCSAccount($accountURL);
$am->login($devuser, $devpass);
$am->createRoom($room, $template);
$token = $session->getAuthenticationToken($secret, $user, $user, 100);
$roomURL = "{$accountURL}/{$room}";
$toret = array(
"data" => array("authToken" => $token, "roomURL" => $roomURL),
"metadata" => array()
);
return $toret;
Any help is much appreciated!
Thanks
Views
Replies
Total Likes
Sure here's what I did, let me know if it helps.
try{
$account->createRoom($roomName, "golden");
}catch(AFCSError $e){
$error_msg = $e->getMessage();
if($error_msg == 'connection-failed'){
//assume room exists already
$roomURL = "$accountURL/$roomName";
sendRoomInfo($accountURL, $roomName, $roomURL, $token);
}else{
//failed with some other problem
genericError("roomcreation", $e->getMessage);
exit();
}
}
Views
Replies
Total Likes
Thanks very much for the quick reply - I have implemented your code into mine, works fine if the room doesn't exist but again I am getting this error, if trying to login to a current room:
' Connection error: Error #1088: The markup in the document following the root element must be well-formed. ' - so I must have made a mistake in adjusting my previous code - I will get back to you once it's sorted...
Views
Replies
Total Likes
Hi there
I can't quite believe it's been almost a year since I originally asked your advice on the createRoom problem I was having! I never did quite get there with the solution, and now having ported my app over to Flex 4, I have come against it again
I have spent so many hours on this, and whilst not liking to ever admit defeat, I just can't quite work out why I still can't log in to a room that already exists, and bypass the 'createRoom' script using try-catch PHP code.
Would you (or anyone else) be able to work out what I am doing wrong here? Any insight would save my sanity! Here's my PHP login code, which works fine when logging in for the first time, and creating the room - however it always causes a 'connection-failed' error when trying to login and the room already exists. I have tested the script within Flash Builder 4 and the try-catch does run, token and room are returned, but I am getting the 403 error: Warning: fopen(https://na2.collaboration.adobelivecycle.com:443/*****) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in C:\wamp\www\derLingo2010\bin-debug\services\lccs.php on line 778
function loginLCCS($username) {
$template = "lessonRoom";
$devuser = "******";
$devpass = "*****";
$secret = "*****";
$host = "http://collaboration.adobelivecycle.com";
$account="*****";
$accountURL = "$host/$account";
//session_start();
$room = strtolower($username);
$am = new RTCAccount($accountURL);
$am->login($devuser, $devpass);
$roomURL = "$accountURL/$room";
try {
$am->createRoom($room, $template);
} catch (RTCError $error) {
$error_msg = $error->getMessage();
if($error_msg == 'connection-failed'){
//assume room exists already
$roomURL = "$accountURL/$room";
}
$session = $am->getSession($room);
$token = $session->getAuthenticationToken($secret, $username, $username, 100);
$toret = array($token,$roomURL);
return $toret;
}
Thank you very much, if you need any more detail then please don't hesitate to ask!
Views
Replies
Total Likes
I may be missing what you are asking for but I took a look at our php code again. It looks like we always get the connection-failed message whenever a room exists and that's how we know it exists already. I seem to remember someone at Adobe telling me that is how it is supposed to work. Anyway after that error we just connect to the room, the connection-failed error doesn't affect us.
I feel like that probably doesn't answer your question though.
-Eric
Views
Replies
Total Likes
thanks Eric. Well that in itself is interesting in that you can still connect. I suppose what I am asking for really is another eye on my PHP code to see if there's any obvious errors. All I really want to do is for Flex/PHP to ignore any errors created on the createRoom function, and continue on and log in to the room. I'll keep trying anyway...
Views
Replies
Total Likes
Did they change the account urls you can use? I see yours is:
$host = "http://collaboration.adobelivecycle.com";
$accountURL = "https://connectnow.acrobat.com/esteimle";
Views
Replies
Total Likes
If you are getting some parsing error my guess is that your account URL is somehow wrong and your are getting an HTML response back from our server (long story)
Can you enable debugging and send the traces you get back ?
RTC::$DEBUG = true
When a room already exists the server returns an HTTP error 403, that is what you should really be testing.
I just found a way to return the approiate error code. You can update your http_post method in lccs.php with the following code (the changes are after fpopen), and I'll integrate this in our scripts for next release:
$context = stream_context_create($opts);
$fp = fopen($url, 'r', false, $context);
if (!$fp) {
if (isset($http_response_header))
$headers = $http_response_header;
else
throw new AFCSError("connection-failed");
} else {
$meta = stream_get_meta_data($fp);
$headers = $meta['wrapper_data'];
}
$statusLine = explode(' ', $headers[0], 3);
if ($fp) {
$resp = stream_get_contents($fp);
fclose($fp);
}
if ($statusLine[1] != "200")
throw new AFCSError($statusLine[1]);
With this code you can catch the exception and ignore it if the code is 403 or process it.
In any case, as I have been saying it a lot lately, please don't rely on our server to keep track of your rooms
If your application tends to create a lot of rooms, keep track of them in your database and use your database to check if they exists already.
Or if you create rooms associated to your users, create the room when you create and add your user to your database. You'll get better performance that trying to create the room every time or trying to test for its existence in our repository.
Views
Replies
Total Likes
With the latest SDK we completed the transition to our "new" LCCS name and "moved" to the new domain.
We actually didn't move, we just have different domains pointing to the same servers. But in the future we may split the ConnectNow services from the LCCS services so at some point you may want to update to the new domains.
Views
Replies
Total Likes
Thanks Raff, I will indeed change my method, and create room when user is added to database, as I can see why that would be more efficient in the long run. I'll let you know how I get on, just in case anyone else comes up against this.
However I have sent you a private message anyway with the trace, as I am still curious as to why it doesn't work! have amended my LCCS.php with the new code, although am unsure as to wha tI should do differently in my PHP login LCCS function.
Views
Replies
Total Likes
Views
Likes
Replies