All done and only got a few bits to install now. And the good news is that the tomcat server now works again.
Phew! I can get back to the 3D stuff again.
Elsewhere there are things that we all miss, yet it takes just one to notice...
All done and only got a few bits to install now. And the good news is that the tomcat server now works again.
Phew! I can get back to the 3D stuff again.
I’ve recently upgraded from Linux Mint 17.3 to 18 and although everything else is working just fine, the tomcat server doesn’t. The client side of a web application works but there’s no joy from the server side so zero RPC calls are working.
A fresh install will be good anyway as it will clear a lot of junk out.
Ah well, should be about 30 minutes to an hour installing most of my software back. It’s handy having a nice 480Gb SSD and decent download speeds.
When my home server Apache is running (basically when my PC at home is on), then the very first test of 3D inside a web page is working…
However, the RPC calls are not working. I’ll get onto that straight away.
After upgrading from Linux Mint 17.3 to 18, I found that the minimum Java available was 8. For GWT projects, up to 7 is allowed because there are issues running with Java 8.
So, I deleted Eclipse ready to install the latest. It installed fine. Still some issues along the way with Java 7 and 8 with GWT.
Eventually I installed Oracle Java 7. So far so good.
After finding that there is no longer support for Android in eclipse and installing all the Android stuff I cleared eclipse again. Actually I removed Eclipse a few times until I got Java 7 and 8 and all the GWT web stuff. Including Java EE version of eclipse.
Now I’ve figured out how to run a GWT project straight out of Eclipse without needing to upload onto the Apache server too. This makes for much faster build times. However, one cavaet is that I will have to create a linux group and add my user to the group next so that Tomcat7 and my user can read/write to the servers home directory.
Having sped up the build times, development of GWT projects will be so much easier and less time consuming. I will only need to deploy to the Apache main server when it has all been done. All I need to do is to save all files that I’ve been editing, click refresh in the server pane in Eclipse and go to the page in the browser. The browser will then tell the project to build itself the changes made.
Good stuff for a few hours of headaches.
Okay, I hit a block when I was starting to think about writing a quick networked multiplayer shoot em up game in LibGdx.
LibGdx texture atlas’s are very handy things because you can store a load of smaller images in one image. This also optimises the GPU draw routines because it doesn’t have to keep swapping textures for each sprite drawn.
I found pre-made free to use sprites fromĀ Kenney.nl, below is a section of what they look like:
Unfortunately though, LibGdx uses .pack files for it’s texture atlas’s and this one come with one that looks like this:
<TextureAtlas imagePath="sprites.png"> <SubTexture name="spaceAstronauts_001.png" x="998" y="847" width="34" height="44"/> <SubTexture name="spaceAstronauts_002.png" x="919" y="142" width="37" height="44"/> <SubTexture name="spaceAstronauts_003.png" x="824" y="0" width="50" height="44"/> ... </TextureAtlas>
Which is completely different to a .pack file.
So without further ado I decided to test out an xml parser to retrieve all the sub-regions from the xml file.
Test code as follows:
[snippet id=”19″]
So, armed with this now, all thanks mainly to working with GWT, I can quickly move on to creating my own class to generate the texture atlas in LibGdx.
Now that I’ve got that working over the internet, there are many things that this kind of thing can be used for. Most of them are obvious, but a few I’ve had in mind for some time now.
As you can see from the above, there’s no limit to what a running server can do.
One thing I will have to do soon is to handle brute force attacks on the server. This happens when a DoS (Denial Of Service) attack occurs, which is a deliberate attack in which lots of data is sent to the server continuously. The simple way around this is to have a damn good fast CPU in the server and to record IP’s that are connecting. If an IP is not requesting the usual data and has attempted X amount of times then it goes onto a block list. Each connection attempt will first check the block list and instantly close the connection if that IP is blocked so that no further time is spent processing the connections request. At this current moment in time the Intel Xeon and the latest Intel i7’s have the cores that could handle DoS attacks.
Multiplayer games requires a whole new line of thinking, especially when they’re real time. Band width can be a pain, but there are many ways to get around this. In one of the above notes, I mentioned ‘local’ data. This comes into play when a players device only needs to receive the local updates in the surrounding area. Although the server will handle all players, it will only send each device its local data.
Anyway, that’s me done for now while I think of what to do next.
Any ideas, then get in touch.
Well, I finally finished off the initial test where I can run an app on my phone or tablet anywhere, click something and it fetches a random image from my PC at home.
The updated sources can be found HERE.
Before I move onto the application itself, I was testing out loading in and scaling a bitmap, when I came across a very annoying Out Of Memory error. The image I was testing was ~4000 x ~3500 pixels and the test was running in the android emulator.
Initially, after using the android logging I found the image wasn’t being scaled and I couldn’t load it in and then scale it. And I didn’t want to up the memory on the emulator.
I know I needed an AsyncTask to do this, plus I needed to figure out how to implement them anyway as I’ve used Async’s in GWT extensively.
Eventually after a bit of digging around I eventually found out how to get everything done and it doesn’t waste any memory.
After this has been done, I want to figure out how to display a large image with a zoom option.
See below for the code…
[snippet id=”15″]
An important part of communicating over the internet is having some security in place. For my own project this will have the server setup so that it only accepts connections from known devices. It will also encrypt data before it is sent and decrypted when the server receives it.
Encryption:
There are many ways to encrypt data:
I’ll be using a system which adds a key and pours in some salt. Now how this is done is using a key to skew the data, and then by splitting the bits of the data up randomly and adding random bits in between, the bitstream will be larger but impossible to decrypt. 2 things will be needed to decrypt the data, the code itself and the key.
Security:
Most of the time, security means logging in with a username and password. The final project will require the device to first log in which will have a timeout feature on it. This is just like session handling in GWT for the web. The login data will still be sent encrypted.
Fortunately, I’ve worked with encryption since 8-bit cpu’s, so this shouldn’t pose a problem for me at all. I’ll have some generic classes written that can be used on both client and server for de/encryption. Apart from the usual login credentials, the client and server will have some hardcoded (still encrypted) transport keys, which can be updated when software is updated. The server can also handle software updates which includes data security updates. This will mean that software that isn’t updated will no-longer work unless it gets an update.
Obviously, this means a lot of boilerplate code, but it will be worth it. And hiding it from a web interface by using TCP, it will be more secure.
One last thing to note about security is server/port attacks. On each socket connection, the server will log the number of requests from an IP address. It it gets too many then it will ignore that IP address for 30 minutes or another set time. This will reduce DoS attacks on the servers port/s.
When the application is transferring data back and forth to the server, most of the communication will be done in one connection. Too many connection attempts will simply be denied.
With the previous post setup I’ve written a very basic example of how to test the server. At the moment, there are no back and forth communications, just a simple send of a 4 byte header.
Run the server program first, and then run the test. These can actually be run in the same order from Eclipse.
The good news is, this also works over the internet. The ‘Global’ in the code hold a string of my web server address and also the port that my router has open.
So, all working as expected.
[snippet id=”11″]
The output from the server will be:
WLGfx Home Server - Starting up Shutdown hook attached TCP Server thread started... TCP Incoming socket handler Got header: HEAD