Coder Social home page Coder Social logo

mage-sdk-unity's Introduction

MAGE Unity SDK

Internal Dependencies

Async

This is a C# implementation of the Async library caolan/async. Though .Net does have Asynchronous methods and paradigms, none of these are usable in Unity due to the fairly old version of mono. This along with the need for familiar APIs for NodeJS developers brought about the need for this library. Asyncライブラリーのcaolan/asyncC#での実装です。 .Netに元にあるAsync方式はMonoのバージョンが古いの理油でUnityで使えません。 加えて、Node.jsの開発者は慣れやすいライブラリーの必要性があるから、こちらのライブラリーを使っています。

EventEmitter

This is a wrapper around C# eventing to provide the familiar EventEmitter class and APIs for NodeJS developers. NodeJS開発者用のEventEmitterのようなクラスのイベントラッパー(C#で実装)。

HTTPRequest

This is a simple wrapper around HTTPWebRequest which provides simple GET / POST API with callbacks. HTTPWebRequestの上で、GET / POSTコールバックが提供するWrapperです。

JSONRPC

JSONRPC is a lightweight JSON RPC library which leverages the .Net HttpWebRequest object along with Newtonsoft's JSON library. Due to the use of HttpWebRequest a Unity Pro license is required to build for IOS and Android. However this will build just fine in the IDE and for desktop applications. JSONRPCというのは .Net HttpWebRequestオブジェックト(Newtonsoft's JSONライブラリーに沿って)を使用する軽いJSON RPCライブラリーです。 HttpWebRequestが使われているため、IOSとAndroidのブイルドを作る為に、Unity Pro ライセンスが必要です。ですが、デスクトップアップとIDEのブイルドを作るために、Unity Proライセンスが必要ではありません。

Newtonsoft.Json.dll

This is the one of the most famous and renowned JSON libraries for C#. However due to the fact that Unity's mono version is severely outdated, many features are not available. (we tried to look for documentation, but could not find anything on what is and isn't available to us) C#での有名なJSONライブラリーです。ですが、UnityのMonoバージョンが古くて複数の機能は使えない状態です。(色々仕様書で調べましたが、何かが使えるか何か使えないかの情報はありませんでした。)

Singleton

This is a collection of lightweight classes that can be inherited to add singleton behaviours to your own classes. 自分のクラスにシングルトン行動を追加が出来る為にこちらの軽いクラスのコレクションを使えます。

Tomes

This is a C# implementation of node-tomes which can be found here node-tomes 詳細のC#バージョンです。

mage-sdk-unity's People

Contributors

almirkadric avatar christopherobin avatar daniel-dressler avatar dinwy avatar kefniark avatar nullorvoid avatar ohwaki avatar stelcheck avatar tokyowizard avatar yuuki77 avatar zsarette avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mage-sdk-unity's Issues

look at another potential JSON library

right now we are using newtonsoft, but this required full .net 2.0 which bloats the size of the build etc
other drawbacks may exist,

we should really make sure using newtonsoft is an educated decision and look at alternatives
(though we did do initial research when we first picked it)

other options:
https://github.com/mtschoen/JSONObject

Move Async's error checking lamba into proper lamba

We tested the suggestion, seems to work fine moving this outside.

(Exception error) =>
{
// Stop iteration if there was an error
if (error != null) {
cb (error);
return;
}

// Continue to next item
currentItemI++;
iterate ();

};

Add websocket support

Without websockets our cost per call is quite high as every request must tear down and setup a tcp connection.

complete or remove event emitter

Right now we have an event emitter, however this is not quite the way C# handles events.
They use a predefined delegate per event, thus each event is explicit.

Either we need to move the entire sdk to do this, or we need to complete the event emitter to be a fully fledged event emitter class.

Missing event emitter functions:

  • listenerCount(eventName)
  • off(eventName, hander) (aka: removeListener)
  • removeAllListeners(optional eventName)

BindingFlags and Invoke Member Unity 2017.1

Description

In the new upgrade with .Net 4.6 Experimental the BindingFlags in SetupModules will need to be updated to

BindingFlags staticProperty = BindingFlags.InvokeMethod | BindingFlags.GetField | BindingFlags.GetProperty;
BindingFlags publicMethod = BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance;

Not sure what changed or whether it is just the experimental version of Unity, but currently this is breaking.

SSL Support

It seems that WebRequest can't properly verify SSL certificates on Android and iOS, might be related to the Mono Version.

Most solutions I've seen online resume at doing the following:

ServicePointManager.ServerCertificateValidationCallback += (o, cert, chain, errors) => true;

Which works but is a terrible solution as it just removes all verifications.
So we need to either find a better HTTP client, or manually rewrite the ServerCertificateValidationCallback to implement a proper verification.

Error if module was not set up.

Ref: https://github.com/mage/mage-sdk-unity/blob/develop/Mage/Module.cs#L86

Description

When attempting to make a call to a module which was not set up, you get a null error.

Desired behavior

Modules are singletons; they should have a protected field that tracks if the module was initialized, and calls should error out early if:

  1. The module has not been initialized
  2. If we attempt to execute a user command that is not defined in the module

cc @nullorvoid @AlmirKadric

setup: feed a namespace instead of each individual module names

Description

Find a way to dynamically find all MAGE modules in need of setup at runtime, and set them up.

Purpose

I believe this would help with:

  1. Not forgetting to add a module to the setup list; this is easy to forget and causes minor time wastes.
  2. Avoiding issues with typos in the list; you cannot make typos in code you do not have to write

Notes

                var modulesNamespace = "MyGame.Mage.Modules";
                var modulesList = new List<string> ();
                var types = Assembly
                    .GetExecutingAssembly()
                    .GetTypes();
                
                foreach(Type type in types) {
                    if(type.IsVisible && String.Equals(type.Namespace, modulesNamespace)) {
                        Debug.Log("MAGE: found module " + type.Name);
                        modulesList.Add(type.Name);
                    }
                }

Since this would depend on reflection, I am not sure if this would play well when pushing on a device; I only tested this quickly on a local project running in the editor, and it seemed to work fine. It would be even better if we could feed in the actual namespace instead of a string representation (to avoid typo there by triggering compile-time errors), but would be happy to research that.

cc @AlmirKadric @nullorvoid @kefniark

HTTPS x509 authentication

Confirm IDs are discarded too soon

This line is problematic:

The server will keep sending those messages until confirmation has been successfully completed. I fear that the loop and its conditions around line 203 will prevent those confirm IDs from ever re-entering the confirmation list.

The behavior would be better if it replicated the JS version which only clears the confirm IDs list on a 2xx response: https://github.com/mage/message-stream.js/blob/e62d35156526204a88369d08a16a336dfff73774/http.js#L49

cc @AlmirKadric @nullorvoid

Implement Unit Test

A module like this one, used in so many project recently, should be at least partially cover by unit test.

I took a look, some part can be easily tested :

  • EventEmitter
  • Logger
  • Tomes

But some other like the mageClient (the more important one) has a bit too much part mixed together to write nice tests.
A refactoring will probably be needed for that to happen.

Readme update

The current readme doesn't tell anyone how to install, nor how to use the SDK. We need to clean this up, make it English-only, and (if deemed useful) move translations to another location.

@AlmirKadric @nullorvoid @kefniark any help with this would be most welcome.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.