AIR server connections - sockets

I am wanting to give back to a small gaming community. The idea is to make an app that acts like a chat client to connect to the game servers. I am trying to grasp the concepts on how connections work through examples I've found on the web, since I am self taught by seeing examples.
So far the examples I found are for connections on the same network. What I need is some kind of example that will allow me to connect from different networks or at least an explanation on what I need to do. Also I need to be able to get around a router without with setting port forwarding on the router.
In the end the app will be connecting to the game developer's server but I need a working app before I get his permission to connect to his servers.
Any help will be most appreciated. If any additional information is needed to help just ask and I'll do my best to fill in the gaps.

That is a very broad question, but I try to give you as much information as possible from by point of view. As I'm not yet sure if you want to have a P2P Connection (game-application to game-application) or a standard server model, I will just mentioned different approaches to this problem.
Adobe has support for P2P since a long time. Read some FAQ, esspecially "How does RTMFP differ from RTMP?" (I try to choose Sources with infographics, as that helped me to understand it).
What you really should start playing with and making first steps in, should be NetConnection. This is the very basic Function that will allow you to communicate to a Server running e.g. PHP or connecting to a Flash Media Server (FMS). FMS is inpartcular interresting for you, as it really boosts the ideas what you game could do, but setting up a FMS is not that easy,to host a own instance is even more complex. So if you come to the conclusion that you want to travel the road of using a FMS, I can suggest you Onyx Server. They mainly marketing theirself as a Streaming service, but in reality you will get access to a FMS for a ok'ish price (FMS instances on Amazon were way worst the last time I checked).
The FMS basicly only a Flash AS2 File with some extra Commands. Your FMS can handle real-time (!) persistent connections (!) with any client that connects to it. Everyone is able to connect to the server at first, and you can then choose in your FMS Script what a client have to bring to the table to stay on the server or is rejected. After that, you have a very string tool for a Game. For example, you could have a game instance connect to it, tell the server that an enemy was hit and the server near-instantly (the speed is really amazing, there is no feeled delay, it really is instant. Its called SharedObjects) pass this information down to the enemy game instance. I used FMS only for one project and it was a very long ride to understand it and work with it, but it was a really nice experience, as you code the Server in the "same" language like the game itself (AS2, AS3 = ECMA).
If you dont want to spend money at this stage, you can use the Adobe RTMFP Instance at p2p.rtmfp.net. It is, as far as I know, only for testing and you will be rejected if you misuse the service for a real project, but for starting and testing it will do. If you use the Cirrus Engine, you can even follow this Tutorial. You will find sample code in there:
// Cirrus connect info
private const SERVER:String = "rtmfp://p2p.rtmfp.net/";
private const DEVKEY:String = "{YOUR_DEVELOPER_KEY}";
// Used to connect to the Cirrus service
private var _netConnection:NetConnection;
_netConnection = new NetConnection();
// Listen for status info
_netConnection.addEventListener( NetStatusEvent.NET_STATUS, onNetStatus );
// Connect to Cirrus using our unique URI
_netConnection.connect( SERVER + DEVKEY );
My adive for you would be: Try getting comfortable with NetConnection. It is really straight forward. When I first started using it, I had a couple of days struggeling and reading a lot on the web, but I learned a lot doing so. You should too. Use NetConnection and try to create two simple AS3/FLA instances of your code that both connect to the same domain (use the adobe rtmfp domain for now) and try to exchange some simple String-Data between these instances.
To take some of the pain of your shoulders, add the minimum amount of listeners to your NetConnection like so:
//Main NetConnector
nc = new NetConnection();
//Troubleshooting Listener
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
nc.addEventListener(NetStatusEvent.NET_STATUS, status_handler);
//nc.objectEncoding = ObjectEncoding.AMF0; //Default
nc.client = this;
nc.connect("https://some-domain");
////////////////////////////////////////////////////////////////////////////////
/// CALL ERROR LISTENER
////////////////////////////////////////////////////////////////////////////////
private function status_handler(e:NetStatusEvent):void {
//trace("NetStatusEvent");
dispatchEvent(new CallEvent(CallEvent.CALL_NATIVE_NET_STATUS, e, true ));
}
private function securityErrorHandler(e:SecurityErrorEvent):void {
//trace("SecurityErrorEvent");
dispatchEvent(new CallEvent(CallEvent.CALL_NATIVE_SECURITY_ERROR, e, true ));
}
You will get alot of errors and netStatus and NetSecuriy Events. Flash will often run into Sandbox-Violation errors when you now know what you are doing. That can be frustrating but if you keep it up, google every error and compare you implementations with the implementation of others, you will wrap your head around this and can do really neat stuff with it.
I recommend you google sources and tutorials for NetConnection and stick to one that is on your level of knowledge.
Good Luck.

Related

Connecting a device to an account

So the title sounds stupid. I'm not really sure how to really word it, but I want someone to help guide me on what to look for. Little back story first so I'm working on a Raspberry Pi project that involves using an LTE service currently I have a dashboard running on a AWS EC2 web server with a simple user working user login.
I have a raspberry pi that is directly pointed to the dashboard/account via an IP address. I want to know how to do something like giving a device an ID and having it connect to an account. So for example with Nest products you have the QR code on the camera you take a photo and that devices get applied to your account.
Is this even possible with Raspberry Pi(I'm sure anything possible, but is it feasible? If so what should I look into or learn how to do such thing. I know its not something that can be answered in a short paragraph just looking for some guidance.
Right, thanks. Well, I think you need to program this into the pi server app. So currently your Pi is reading a sensor and sending this data to the web server, right? I suppose you have a daemon running, taking readings, and doing an API REST call to the server backend, correct? So what you want is to have a unique code for each pi, sent with the API call, and then on your DB server side,you store all readings related to their unique code.
You don't need to pre-validate this code, there are GUID generators that will create a number for you, guaranteed to be unique for all eternity, so on the PI, you set it up once, to create the PI's code, and use it from then on. Now, server side, then associating a device with a user is a matter of choosing the data associated with a given gui. And I think that covers it.
You can improve on this basic idea by giving it more thought, but I think it's a good starting point! Do let me know if I can help you with anything else!

hosting a game online using NIO Kryonet, performances issues and workflow and other issues

So I have been coding a game using Libgdx, and THE very simple and powerful kryonet(SERVER-CLIENT) for multiplayer section . So far I could properly do the multiplayer over LAN and it works great!. I'm Starting to do the Online part of multiplayer section, in which two players will have a match randomly(the opponent would be randomly chosen). OK I have these questions that I think Is so simple and sadly I couldn't find any proper Answers:
I have a web application running on my server that could be like:
Public class myClass {
.
.
.
public main(){
Server server = new Server;
networkRegisterer.register(server);
server.bind(port.UDP,port.TCP);
server.start;
server.addListener(new ServerListener);
.
.
.
}
So my question starts with that:
Suppose that I have 500 players playing online(250 matches playing know)
I know that I'm not being specific but how do I manage this? should I create one ServerListener per Match(for 2 players)?should I create separate servers for each match? should I have just one server forwarded to one port and somehow manage the matches being played? should I use several ports(and then several servers) in order to control the traffic?
and another important question is that how am I supposed to check the Server performance for issues like data transfer Speed ?? (I mean before publishing the app obviously I cannot test my Server performance since I don't have 500 clients!!!!) . is there any way that I can run a simulation with a lot of clients without having actual clients?
Sorry if my questions look naive, I have done a lot of java experiences but not any Server-Client programming.

PJSIP via CLI on Raspberry

I am new to Raspberry and VOIP. I am interested to make a door intercom system using raspberry, as I read most of the post here and those are really helpful,one of the raspberry is acting as server (Asterisk and PBX). I was able to call using sflphonebut that was only for desktop mode and I am interested to call using CLI and for that I installed "PJSIP" as reffered by most of users, but don't have any idea what to do next (I mean how should i start). As it is written after installation I am supposed to try for "pjsua" and "pjsystest" in pjsip-apps/bin, but it doesn't ring any bell for me.
Sorry for my level as beginner but if you don't begin how are you supposed to masters it.
I shall be very thankful.
so i can't explain all of the stuff you need to know, but with this Site you should be able to register to you PBX. It's an documentation to the high level API of PJSUA. If you go further on that site they will lead you through the things you have to do to establish a call.
Although this can be very frustrating because there are many error that can appear. There are some python test application under pjproject/pjsip-apps/src/python/samples, here you should firstly try to establish a call between two clients to be sure you server is well configured.
Just for info, the dest_uri you have to give in the call.py is like so sip:ip:port and you have to change the values in the register.py to your client infos. Then run the register.py in one shell and the call.py in an other shell.
Hopefully i could help you over some barriers, feel free to ask if something was unclear.

WoW Addon to REST API

I´m going to create a web service for learning purposes and wanted to combine it with my WoW Hobby. My goal would be to create a "simple" Addon, which tracks my battleground activity in real time.
So when queuing for AB it enters my data in an db and when I´m out of the BG it should delete the db entry. The information should be stored in an JSON/XML-File and whenever the bg-status changes it should execute the post/update on the DB on the RESTful service.
The real time communication is very important here and I would like to know which ways of communicating to a web service are available, so I could directly dive in and create a solution.I´d like to have resources instead of solutions.
Currently I´m not used to LUA, but would like to learn it to get the knowledge of creating such a service.Which sites are you suggesting for learning LUA, especially the WoW-API?
Addons only write to disk when you log out of a character (and read that saved data when you log in) so what you intend would not be possible.*
More involved ways of communicating with the rest of the computer or even the internet are prohibited to prevent the gain of certain advantages, an example would be looking up details about your Arena opponents.
* Well, there are certainly some ways, but rather complicated ones: a program monitoring sound output to check when the BG queue pop sound is played, or a screengrabber that registers when the BG score screen comes up (which can be viewed during the match though, too)

Send server information to client

Last semester we had to develop the game Ludo in JavaScript and HTML/CSS. That was pretty easy. Now we have to develop a backend with GWT (Java) to create a multiplayer game. Sadly, we haven’t got much information on how to develop with GWT and the exercise is quite difficult at the beginning.
At the moment I am trying to create a kind of lobby where different players can join.
My idea was to use some input fields, where the player could enter his name and join the lobby. But I don’t know how to give the other clients the information that a new player has joined.
I created an asynchronous interfaces (RPC) where a player could submit his name to the server (Like this example). This works ok. But how should I share this information? Our docent said we should use JSON to share information’s, but I don’t know how this should help in this situation.
Is there a way to send information’s to the clients? I read a lot and just find to use additional libraries as gwt-comet.
I have really now clue how I could go on. I’m thankful for every help and information!
Greetz
You have two options: push and pull.
"Pull" option:
Other players get required information when they join the lobby and/or do something else. You can also schedule to pull this information periodically (like once every 10 minutes). You can use the same RPC mechanism to get data from server to a client. "Pull" means that a client initiates the request and server responds with the information.
"Push" option:
When a new player joins, the server pushes this new data to all other players. The best solution depends on your game implementation. Comet is a good option, as Jean-Michel mentioned, but it's more complicated and "expensive" from resources point of view. You should use this option if you need real-time status updates for your game.
I would suggest Errai and ErraiBus in particular. From Java perspective you are only sending some events via event bus (observer GoF pattern) and all the magic with Ajax Push is happening behind the scenes.