I manage to publish but not to connect to that stream from outside...

Ask any questions or talk about OpenTok here!

I manage to publish but not to connect to that stream from outside...

Postby netusco » Fri Feb 18, 2011 3:07 am

Code: Select all
Archived Post


woW yes lots of info in your answer that's great!
yes I guess I had digested all this info.
from it I extract that there is no problem to use a statci sessionId (hard
coded) if what I need is a single chat room where people can connect to one
single sessionId.
And that's my intention in the beginning.
later on though I would like to reproduce this chat room for diferent events
that could run at the same time.
One way could be to store some valid sesionIds and use them for each chat
room I guess. But it would be probably better if the sessionId was
generated. A diferent one for each diferent URL address so diferent
webpage.
In this case I still have the same problem. Each connection asks to create a
new sessionId and instead of being returned the one created for each page
it returns one new for each connection. Wouldn't it be easy to show me one
example that uses the php libraries and the basic.html
I just don't understand because I use the exact same code download and it
gives me this problem. I wonder if there's something to modify...
The simple case I'm trying to do is to connect several people to one single
sessionId in one single webpage. To be extending it to multiple webpages
(multiple sessionsIds) where multiple people could connect together 1
sessionId per page.
Meanwhile I use the hardcoded solution...
thanks
Was this post helpful? (0)
netusco
 

I manage to publish but not to connect to that stream from outside...

Postby Thomas Osowski » Fri Feb 18, 2011 12:33 pm

Code: Select all
Archived Post


I think I understand the issue a bit better now.  It might help to

think of generating new sessions as a separate process to a browser

connecting to a video chat.

If you know that you'll only need 10 unique sessions you could

generate these off-line and store them on the server (in a DB hard-

coded array etc.).  Now when a browser connects the page doesn't

need to generate a new session because they already exist.  The

application would then need to handle taking the user/browser/

connection to the correct page which has access to a sessionId.

To continue this example say you have 10 sessions where room 1 is a

general discussion and rooms 2-10 are 1:1 chats.  You could direct

users to the main page which will point users to the session

associated with room 1 ( room1 has Id A which is accessed through DB

hard-coded etc.).  If the user wants a private chat they they can go

to room 2 (Id B) which is associated with another session (accessed

through DB ...).  Only when all rooms are full does the server need

to 'generate' a new chat room with a new sessionId.

The next step -- now that your application can generate sessions -- is

to build out the session management logic for the site.  Ideally the

site will have access to a DB storage to handle these but it is also

possible to pass the sessionIds between connections (again using some

application-side logic).

We are looking to expand on our PHP server-side code examples in our

next release.  Here we show the technique where the sessionId is

passed through the URL to allow multiple pages to connect to the same

session.  Please note that this is provided purely as an example and

is no way the only method to manage sessions.

 //Check if the URL contains a sessionId.  If not generate a new

session

 if($_REQUEST['sessionId']) {

        $sessionId = $_REQUEST['sessionId'];

 } else {

        $session = $apiObj->create_session($_SERVER["REMOTE_ADDR"]);

        $sessionId = $session->getSessionId();

 }

//Display the following link to session that another browser can

load.  Note that refreshing

//  the first page may change the sessionId

var myText = '<?php echo "http://".$_SERVER["SERVER_NAME"].

$_SERVER["REQUEST_URI"]."?sessionId=".$sessionId; ?>';

The previous should show the first browser initiating a new session

and after copying the link to another browser (connection) another

page can connect (publish/subscribe) to the first session.

Let me know if this helps

Thomas

tho...@tokbox.com

On Feb 18 2:07 am netusco <ernestcon...@gmail.com> wrote:

- Hide quoted text -
Was this post helpful? (0)
Thomas Osowski
 

I manage to publish but not to connect to that stream from outside...

Postby netusco » Fri Feb 18, 2011 1:42 pm

Code: Select all
Archived Post


ok solved.
Somehow I should excuse... as I was not understanding how these sessionIds
where functioning.
Now it's clear. And what I was lacking was a server side code to pass the
same sessionids when needed or create new ones.
In my case I do it through a database storage...
I explain for whoever needs an example.
In my app a user creates an event that will require a chat with that
event_manager.
So I'm actually creating new sessionsIds when that event is created. That
event is related through HABTM associations with the user and the
event_manager.
Then when the event is happening user and event_manager will connect to one
chat room that will have the same sessionId of the event as they will
request it from the database.
If other events with other users and events_managers are happening at the
same time and at the same webpage they shouldn't interact with each other as
each event has it's own sessionId generated and stored at the time of it's
creation.
I hope this makes sense to whoever needs examples... at least finally it
makes sense to me thanks again for your dedicated help Thomas and
congratulations to you and the team for your project looks great.
I'm looking forward the improvements. In my case I need to shut down all
audios and forbid using them (I know you work on that) and the text chat.
Was this post helpful? (0)
netusco
 

Previous

Return to Discussion and Questions



Who is online

Users browsing this forum: No registered users and 1 guest

cron