HttpWebRequest and HttpWebResponse Network supported ?

Hello All

First time poster so be nice :stuck_out_tongue:

We don’t plan to make any money out of this so for now this will be using the free version of Unity and not the Pro version.

Anyway we are porting our browser based game over to Unity to be used for the game client and the server code is written in PHP and uses a MySQL database.

We are in the middle of changing our server code to serialize just the data we need using JSON and then compress it using GZip or Deflate etc, that’s all fine.
We are also aware that we need to put all of our images, sounds etc, basically all our content as assests that’s all fine as well.

The issue is can we use classes like the HttpWebRequest and HttpWebResponse classes from the System.Net namespace or are we stuck using the WWW class from the UnityEngine namespace?

I know HttpWebRequest and HttpWebResponse “may” (not tested as yet) work on Windows, but will there be an issue on say Linux, Mac OS or even mobile devices like iOS or Android etc, because I know System.Net.Dns.GetHostEntry(“domain.host.etc”) doesn’t work on Android with release code.

The reason that I ask is that WWW is so limited in what it can do, granted it does do what it says on the tin, but where we already have our own class that can already handle the Web Requests, Responses and compression etc. which is currently being used in our remote admin application, so if we could use that then that would be great.

But its not too much of an issue if we have to use Unity’s WWW class, just something we will have to work around.

Thanks

Paul.

Well, I have been playing about with the WWW class which was working ok until I tried to an support for Web Compression, seems that Unity or Mono doesn’t support DeflateStream or GZipStream, which kind of sucks.

So I went searching and after a while found the Mono GitHub and created a Library with a namespace of Web.Compresion to handle the web compression, compiles all fine, and the Unity Editor said all was fine, so I run it.

Now it failed with the following Error:

DllNotFoundException: MonoPosixHelper
Web.Compression.DeflateStreamNative.Create (System.IO.Stream compressedStream, CompressionMode mode, Boolean gzip)

Web.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen, Boolean gzip)
(wrapper remoting-invoke-with-check) Web.Compression.DeflateStream:.ctor (System.IO.Stream,Web.Compression.CompressionMode,bool,bool)

Web.Compression.GZipStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen)
(wrapper remoting-invoke-with-check) Web.Compression.GZipStream:.ctor (System.IO.Stream,Web.Compression.CompressionMode,bool)

TestWebCompresion+<GetData>c__Iterator0.MoveNext () (at Assets/Scripts/TestWebCompresion.cs:132)

I have also noticed some lines saying “License error. This plugin is only supported in Unity Pro!” not sure how I got those warnings.

Anyhow if Web Compression (GZipStream, DeflateStream) is only for Pro version, then that kind of sucks :frowning: just means that I will have to send everything uncompressed which may be an issue later on when I have loads of data to send :frowning:

However its not all bad at least we have access to the “System.Security.Cryptography” namespace which gives us class functions like “RSAOAEPKeyExchangeFormatter” etc.

Right back to coding.

Paul