Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Developer
sidirgid
Posts: 5
Registered: ‎12-23-2010
My Device: Not Specified
Accepted Solution

SocketServer ---AIR-- for server-client (P-P kind of) issue

I am trying to make use of Air's socketServer to build a server which will act as a host for other playBook users to connect to.. In simple terms am trying to build a server that will can be hosted by the user from the application. But am not able to get this working. Any help will be greatly appreciated..

 

Thanks a lot...

 

 

Regards,

Sid.

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: SocketServer ---AIR-- for server-client (P-P kind of) issue

You haven't really provided enough information to get much help yet. There are many potential issues with writing servers, starting with whether the PB is set up to allow external connections to it... among other things, the presence of a firewall can prevent that. You say you can't get it working, but what have you tried? What are the symptoms of failure? Have you condensed your code down to the smallest example which demonstrates the problem? Are you stuck on the basics, maybe not ever having written socket code before? It's very difficult to infer anything from your post. If you can give us more info, someone can either reassure you that building servers on the PB works, or can post sample code demonstrating a basic server, or something like that.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: SocketServer ---AIR-- for server-client (P-P kind of) issue

hey sidirgid,

 

welcome to the forums! i have yet to work with my own socket servers and listeners but i did bump into this article and bookmarked it earlier. it pertain to what you are trying to accomplish:

 

http://www.adobe.com/devnet/air/flex/articles/creating_socket_server.html

 

it covers the basics of a listener app and links to more indepth articles. hope that helps. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
New Developer
sidirgid
Posts: 5
Registered: ‎12-23-2010
My Device: Not Specified

Re: SocketServer ---AIR-- for server-client (P-P kind of) issue

Hi peter...

I guess I provided too feeble information. Well, I initially developed my application to connect with a Java server which worked flawlessly through the PB simulator. Then I came across the article regarding socket server usage and tried to get it working with my application.

 

I am not sure if PB allows external connection..:smileyindifferent: (But communication with external server was working)

 

I couldnt test it by running it from standalone swf because flash player does not include socketserver classes. Thus tried to test it inside simulator. (not sure of the problem)

 

I did not consider handling security sandbox issue and policy files yet..

 

I am stuck at my issue and wanted a different view at it, thus requested for help here..

 

Would be glad to notify of anything else you will need to better understand my problem...

 

Regards,

Sid..

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: SocketServer ---AIR-- for server-client (P-P kind of) issue

 


sidirgid wrote:

 

I am not sure if PB allows external connection..:smileyindifferent: (But communication with external server was working)

 

I couldnt test it by running it from standalone swf because flash player does not include socketserver classes. Thus tried to test it inside simulator. (not sure of the problem)


That helped.  Note that connections from a client app to some external server are different in a number of ways from connections to your software acting as a server.  The fact that one works doesn't entirely help to say whether the other works.

 

In this case, I think the problem is pretty basic, and likely not surmountable with AIR (at least for now).  If you check the docs, you'll see that it will work only if ServerSocket.isSupported returns true.  I just checked and on the PB simulator it is false.

 

The docs also say that ServerSocket  "is not supported on mobile devices".

 

Unfortunately, it looks like at least for now you'd have to wait for the Java or native SDKs to do servers on the PlayBook.

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Developer
sidirgid
Posts: 5
Registered: ‎12-23-2010
My Device: Not Specified

Re: SocketServer ---AIR-- for server-client (P-P kind of) issue

ThankYou a tonne peter.. Its bad news for me but atleast it saved me from wasting a lot of time. Hope serversocket get their way into PB..

 

Regards,

Sid.:smileyhappy:

Regular Contributor
renaun
Posts: 86
Registered: ‎10-25-2010
My Device: Not Specified

Re: SocketServer ---AIR-- for server-client (P-P kind of) issue

You can use the AIR/Flash Player API's called NetGroup and GroupSpecifier to use NetConnection's RTMFP to create a local multicast scenario. This allows for device discovery and communication between AIR apps on the same network. That means you can use this in you PlayBook apps and have them find each and communicate. Here is the source code for a game that uses this technique that I have been demoing lately, and specificaly an app I demo'd at the MeetThePlayBook events.

 

http://renaun.com/blog/2010/12/pickquick-source-code/

blog: http://renaun.com
twitter: @renaun
New Developer
sidirgid
Posts: 5
Registered: ‎12-23-2010
My Device: Not Specified

Re: SocketServer ---AIR-- for server-client (P-P kind of) issue

Thanx a lot renaun...

Your post helped me out a lot.

 

And yes, it works...

 

Regards,

Sid.

Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: SocketServer ---AIR-- for server-client (P-P kind of) issue

@renaun:  Thanks for posting that link.  I copied down the source code and source code for the library, but there are some class definitions that are unknown to 0.9.1 since they appear to be still Beta for the Flash framework.  They include GroupSpecifier and NetGroup.  Is there a way to get those classes so the library can compile?  I want to see if I can include P2P in one of my apps being reviewed with BB.

Regular Contributor
renaun
Posts: 86
Registered: ‎10-25-2010
My Device: Not Specified

Re: SocketServer ---AIR-- for server-client (P-P kind of) issue

NetGroup and GroupSpecifier are API's since 10.1 which means you need to tell your project to target that player. I am not sure how you have your project setup to help figure out your specific issue. are you using Flash Builder 4 or Burrito, what type of Project did you create?

 

For example Flex 4.1 SDK targets 10.0, and Flex Hero (4.5) targets 4.5, but AIR 2.5's airglobal.swc has all the 10.1 API's (and BB SDK requires the AIR 2.5 SDK so it should have the right bits).

 

FYI, the compiler argument for mxmlc to do this is -target-player=10.1.0

 

 

blog: http://renaun.com
twitter: @renaun