Welcome Guest Search | Active Topics | Members | Log In | Register

ServerPush example Flex side problems Options · View
kwantm
Posted: Friday, April 23, 2010 1:37:24 AM

Rank: Newbie Coder
Groups: Member

Joined: 4/22/2010
Posts: 12
Points: 36
Location: Netherlands
Hi,

Iam running the ServerPush example and my Flex client side code is not receiving the server side generated messages. I have debugged the server side and can see that it generates random messages.

I have generated my client side flex code using weborb code generation for Flex 3.
My setup are two seperate projects. The first is the java backend running weborb and my ServerPush code, the second and last is a separate Flex frontend running the client side flex code.

The generated code does not work out of the box. It cannot find the correct url to connect to (it gives me http://weborb.wo, which should be http://localhost:8080/MyContext/weborb.wo)

To atleast get it to connect to the server side code I have added the following code to the constructor of the generated code:
Code:

      public function ServerPush( model:ServerPushModel = null )
      {
        remoteObject  = new RemoteObject();
        remoteObject.source = "weborb.examples.messageserver.ServerPush";
        var _endPoint:String = "http://localhost:8080/WebOrbPOC/weborb.wo";
        var CHANNEL:String = "weborb-rtmp";
        var cs:ChannelSet = new ChannelSet();
        var myAMF:Channel = new AMFChannel(CHANNEL, _endPoint);
        cs.addChannel(myAMF);
        remoteObject.channelSet = cs;
        remoteObject.destination = "GenericDestination";
        remoteObject.startListening.addEventListener("result",startListeningHandler);
        remoteObject.addEventListener("fault", onFault);
        
        if( model == null )
            model = new ServerPushModel();
   
        this.model = model;

      }


After adding this code, the client can connect to the serverside ServerPush and I see a message being generated. But nothing else. I have added breakpoints to my resulthandler, but nothing happens.

Iam using all default config files, I have added in my flex compiler settings the weborb-config, but to no avail

Anyone any suggestions to solve this problem ? how do I connect to the RTMP channel correctly?

http://nl.linkedin.com/in/marcdekwant
Mark Piller
Posted: Friday, April 23, 2010 6:30:24 AM

Rank: Administration
Groups: Administration

Joined: 8/21/2006
Posts: 1,607
Points: 4,082
Location: Frisco, TX
Can you describe in greater details what exactly you're trying to accomplish?

The generated code will use the default endpoint URL, which is a relative URL - "weborb.wo". That means if your Flex application is loaded from the web server, it will use the relative URL to communicate with the server. For example, if your Flex app is loaded from http://localhost:8080/foobar/MyFlexApp.html, it will use http://localhost:8080/foobar/weborb.wo as the remoting URL. What I suspect you have in your case is your Flex application was loaded from the file system, so the URL in the browser started with "file://...". Obviously that will not work with the relative URLs.

The sample code you posted does just a remoting invocation. I am not sure how you can get Server Push with that.

Mark

Mark Piller
Midnight Coders, Inc.
twitter: midnightcoder
blog: blog.themidnightcoders.com
website: www.themidnightcoders.com
kwantm
Posted: Friday, April 23, 2010 7:18:29 AM

Rank: Newbie Coder
Groups: Member

Joined: 4/22/2010
Posts: 12
Points: 36
Location: Netherlands
Hi,

Thank you for the reply. That is correct, I am loading the flex app from file system. That is why Iam providing the complete url to the server.

You are right to point out that this is not ServerPush. But that is exactly my question. I have no clue how to get it done with weborb. There is some documentation for producers and consumers, but that does not seem to work when you load your app from filesystem.

Can you point me to a flex example with rtmp using the Serverpush serverside example code?

Kind regards,

Marc

http://nl.linkedin.com/in/marcdekwant
Mark Piller
Posted: Wednesday, May 12, 2010 9:23:48 AM

Rank: Administration
Groups: Administration

Joined: 8/21/2006
Posts: 1,607
Points: 4,082
Location: Frisco, TX
Please see this blog post for an example demonstrating data push:

http://blog.themidnightcoders.com/index.php/2010/05/12/rtmp-data-push-from-java-to-flex/

Regards,
Mark

Mark Piller
Midnight Coders, Inc.
twitter: midnightcoder
blog: blog.themidnightcoders.com
website: www.themidnightcoders.com
kwantm
Posted: Friday, May 14, 2010 12:49:45 AM

Rank: Newbie Coder
Groups: Member

Joined: 4/22/2010
Posts: 12
Points: 36
Location: Netherlands
Thank you very much.

I will go to work with this.

kind regards,

Marc

File Attachment(s):
WebOrbPOCJava.zip (3,641kb) downloaded 38 time(s).
WebOrbPOCFlex.zip (1,349kb) downloaded 36 time(s).
classes.zip (25kb) downloaded 29 time(s).




http://nl.linkedin.com/in/marcdekwant
kwantm
Posted: Monday, May 17, 2010 3:13:08 AM

Rank: Newbie Coder
Groups: Member

Joined: 4/22/2010
Posts: 12
Points: 36
Location: Netherlands
Hi,

I have tried the example, but I can not get it to work. I always get "Unable to connect to WebORB". Furthermore, the server-side part is never invoked. When I put a breakpoint in the public boolean appStart(IScope app) method, it never gets there, although I can see that the code is present in my runtime environment.

Kind regards,

Marc


http://nl.linkedin.com/in/marcdekwant
kwantm
Posted: Monday, May 17, 2010 3:29:42 AM

Rank: Newbie Coder
Groups: Member

Joined: 4/22/2010
Posts: 12
Points: 36
Location: Netherlands
Hi,

I have added 2 zip files containing both my projects. Can you tell me what Iam doing wrong?

the zip with java is a Maven 2 project containing server side code + weborb in one. This project runs weborb and uses my custom code to push messages. The flex is your example code in a flex 3 project.

I hope we can get it to work.

Kind regards,

Marc

http://nl.linkedin.com/in/marcdekwant
Mark Piller
Posted: Monday, May 17, 2010 5:50:42 AM

Rank: Administration
Groups: Administration

Joined: 8/21/2006
Posts: 1,607
Points: 4,082
Location: Frisco, TX
I do not see any attachments or links where I could download your files.

Mark

Mark Piller
Midnight Coders, Inc.
twitter: midnightcoder
blog: blog.themidnightcoders.com
website: www.themidnightcoders.com
Mark Piller
Posted: Monday, May 17, 2010 9:04:07 AM

Rank: Administration
Groups: Administration

Joined: 8/21/2006
Posts: 1,607
Points: 4,082
Location: Frisco, TX
There is a problem in your datapush-service-web.xml. The ID of the second bean should be "datapush.scope", you currently have it as "messservice.scope".

Mark

Mark Piller
Midnight Coders, Inc.
twitter: midnightcoder
blog: blog.themidnightcoders.com
website: www.themidnightcoders.com
kwantm
Posted: Monday, May 17, 2010 10:35:26 AM

Rank: Newbie Coder
Groups: Member

Joined: 4/22/2010
Posts: 12
Points: 36
Location: Netherlands
hi,

Thank you for your analysis of my code. I will correct this when I am at work.

Kind regards,

Marc

ps. did you have any other problems with my code?

http://nl.linkedin.com/in/marcdekwant
daslicht
Posted: Sunday, October 31, 2010 5:26:37 AM
Rank: Newbie Coder
Groups: Member

Joined: 8/4/2010
Posts: 14
Points: 36
Mark Piller wrote:
Please see this blog post for an example demonstrating data push:

http://blog.themidnightcoders.com/index.php/2010/05/12/rtmp-data-push-from-java-to-flex/

Regards,
Mark


Hello,
I tried the example nut I get an error at the foillowing line :

Iterator connectionsIterator = this.scope.getConnections();

Type mismatch: cannot convert from Collection> to Iterator



I am a Flex Developer(DigitalMedia MSc. Student) and I like to use WebOrb for the following:

* RTMP Radio Station with multiple channels (genres)
(* Audio Playback on demand)
* Chat (eventually with video)

To archive those goals I need some starting help, some examples , documentation anything what might help me.
Mark Piller
Posted: Sunday, October 31, 2010 5:55:10 PM

Rank: Administration
Groups: Administration

Joined: 8/21/2006
Posts: 1,607
Points: 4,082
Location: Frisco, TX
Any chance you could post here the full stack trace you're getting?

Thanks,
Mark

Mark Piller
Midnight Coders, Inc.
twitter: midnightcoder
blog: blog.themidnightcoders.com
website: www.themidnightcoders.com
kwantm
Posted: Monday, November 01, 2010 1:53:02 AM

Rank: Newbie Coder
Groups: Member

Joined: 4/22/2010
Posts: 12
Points: 36
Location: Netherlands
Hi

here is an example from my working application

Code:

import java.util.Iterator;
import java.util.Timer;
import java.util.TimerTask;

import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.service.IServiceCapableConnection;

import weborb.messaging.WebORBApplication;

public class PushServiceMockImpl extends WebORBApplication {
    
    private Timer pushTimer;
    
    public boolean appStart(IScope app) {
        boolean started = super.appStart(app);
        if (started) {
            pushTimer = new Timer(true);
            pushTimer.scheduleAtFixedRate(new DataPushTask(), 0, 15000);
        }
        return started;
    }
    
    public void pushAlertsToClients(String message) {
        Object[] args = new Object[] { message };
        Iterator connectionsIterator = this.scope.getConnections();
        while (connectionsIterator.hasNext()) {
            IConnection connection = connectionsIterator.next();
            if (connection instanceof IServiceCapableConnection) {
                ((IServiceCapableConnection) connection).invoke("myPush",args);
            }
        }
    }
    
    class DataPushTask extends TimerTask {
        @Override
        public void run() {
            pushAlertsToClients( "push message" );
        }
        
    }

}


You also need a configuration for red5 for this service. Unfortunately I cant seem to get it to show up in a post. But there are examples in de weborb packages.

and not to forget an important piece of code you must add to your running weborb/red5 instance
You must add a service config file reference (see above) in the beanrefcontext file.

This is not a complete example, but sould get you on your way to a running setup.

Furthermore the Error you had in Java: try Iterator it = yourcollection.iterator();

Marc


http://nl.linkedin.com/in/marcdekwant
daslicht
Posted: Monday, November 01, 2010 5:04:44 PM
Rank: Newbie Coder
Groups: Member

Joined: 8/4/2010
Posts: 14
Points: 36
Mark Piller wrote:
Any chance you could post here the full stack trace you're getting?

Thanks,
Mark

pardon, I don't understand, Eclipse is just displaying that error above.
Mark Piller
Posted: Monday, November 01, 2010 7:52:15 PM

Rank: Administration
Groups: Administration

Joined: 8/21/2006
Posts: 1,607
Points: 4,082
Location: Frisco, TX
Try changing Iterator to Collection and it should compile then.

Mark

Mark Piller
Midnight Coders, Inc.
twitter: midnightcoder
blog: blog.themidnightcoders.com
website: www.themidnightcoders.com
theorb
Posted: Tuesday, January 31, 2012 6:02:33 AM
Rank: Newbie Coder
Groups: Member

Joined: 1/26/2012
Posts: 16
Points: 42
Changing from Iterator to Collection didn't work for me. Is there an updated example of RTMP Data Push from Java to Flex somewhere? The code here doesn't compile...
theorb
Posted: Tuesday, January 31, 2012 6:13:04 AM
Rank: Newbie Coder
Groups: Member

Joined: 1/26/2012
Posts: 16
Points: 42
It looks like I ran across the updated source in another form from the post here. This seems to be compiling fine:

Collection> connections = scope.getConnections();
Object[] args = new Object[] { "Server time is " + System.currentTimeMillis() };

for( Set connectionSet : connections )
for( IConnection connection : connectionSet )
if( connection instanceof IServiceCapableConnection )
((IServiceCapableConnection) connection).invoke( "setLogText", args );
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.259 seconds.