Esempio n. 1
0
            public IEnumerator CreatePlayerRoutine(string playerId, string password, IPlayerApi caller)
            {
                string uri  = NetworkSettings.instance.BaseUri() + "/api/players/create";
                var    form = new WWWForm();

                form.AddField("new_player_id", playerId);
                form.AddField("new_player_password", password);
                WWW www = new WWW(uri, form.data, form.headers);

                yield return(www);

                if (www.error != null)
                {
                    caller.OnPlayerCreateError(www.error);
                }
                else
                {
                    MemoryStream stream = new MemoryStream(www.bytes);
                    Player       player = Serializer.Deserialize <Player>(stream);
                    caller.OnPlayerCreated(player);
                }
            }
Esempio n. 2
0
            public IEnumerator CreatePlayerRoutine(string playerId, string password, IPlayerApi caller)
            {
                string uri = NetworkSettings.instance.BaseUri() + "/api/players/create";
                var form = new WWWForm();
                form.AddField("new_player_id", playerId);
                form.AddField("new_player_password", password);
                WWW www = new WWW(uri, form.data, form.headers);
                yield return www;

                if (www.error != null) {
                    caller.OnPlayerCreateError(www.error);
                } else {
                    MemoryStream stream = new MemoryStream(www.bytes);
                    Player player = Serializer.Deserialize<Player>(stream);
                    caller.OnPlayerCreated(player);
                }
            }