NeoNetwork is a class library to provide a simple access to Unity3D's networking stack.
If you don't have access to Microsoft VisualStudio you can just use Unity3D and its compiler. Or use your VisualStudio installation in combination with Visual Studio Tools for Unity to compile a DLL-file, which can be included into your project.
- Clone the repository
- Copy the files from
Assets\NeoNetworkinto your project
- Clone the repository
- Open the folder as a Unity3D project
- Install the free Unity Testing Tools from the AssetStore
- Install the free Visual Studio Tools for Unity and import its Unity-package
- Open
UnityVS.NeoNetWork.sln - Build a DLL-File
- Import the DLL into your Unity3D project
This library separates between the concept of a HTTP client and a HTTP request performer. The client acts as a facade to simplify the complexity of HTTP communication. The actual request performer must implement the IRequestPerformer interface.
In the simplest usage one you simple instrument the provided UnityRequestPerformer which uses the native Unity provided UnityEngine.WWW class.
var factory = new UnityRequestPerformerFactory();
var client = new Client(factory);
client.Get("http://www.neopoly.com", response => UnityEngine.Debug.Log(response.Body));As the UnityEngine.WWW doesn't support the concept of cookies the Client will create an own ICookieJar to support them. You can also use a shared
CookieJar if needed:
var factory = new UnityRequestPerformerFactory();
var cookies = new CookieJar();
var client1 = new Client(factory, cookies);
var client2 = new Client(factory, cookies);
// Getting a session via a cookie
var data = new Dictionary<string, string>(){
{"username", "foo"},
{"password", "boo"}
};
client1.Post("http://www.neopoly.com/login", data, response => UnityEngine.Debug.Log(response.Body));
// Use the same cookie for a second client
client2.Get("http://www.neopoly.com", response => UnityEngine.Debug.Log(response.Body));- At the moment cookies are parsed from the response's header but don't respect the bounded domain. So they will be sent to any host.
- Due the decision from Unity to return the HTTP response headers as a
Dictionary<string, string>only oneSet-Cookiefield can be respected per response.
You can run the tests using the offical Unity Testing Tools. Just install the Unity package and use the Unit Test Runner.
- Support domain-based cookies
For the license of this project please have a look at LICENSE.txt