/// <summary>
        ///     Login with the specified username and password.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        public static void Login(string username, string password)
        {
            //Stop people from simply spamming the server
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                return;
            }

            //Build the data to send
            using (DarkRiftWriter writer = new DarkRiftWriter())
            {
                writer.Write(username);
                writer.Write(SecurityHelper.GetHash(password, hashType));

                //Choose the connection to use
                if (connection == null)
                {
                    if (DarkRiftAPI.isConnected)
                    {
                        //Send via DarkRiftAPI
                        DarkRiftAPI.SendMessageToServer(
                            tag,
                            loginSubject,
                            writer
                            );

                        BindIfNotBound();
                    }
                    else
                    {
                        //Called if you try to login whilst not connected to a server
                        Debug.LogError("[LoginPlugin] You can't login if you're not connected to a server! (Do you mean to use DarkRiftAPI?)");
                    }
                }
                else
                {
                    if (connection.isConnected)
                    {
                        //Send via DarkRiftConnection
                        connection.SendMessageToServer(
                            tag,
                            loginSubject,
                            writer
                            );

                        BindIfNotBound();
                    }
                    else
                    {
                        //Called if you try to login whilst not connected to a server
                        Debug.LogError("[LoginPlugin] You can't login if you're not connected to a server!");
                    }
                }
            }
        }
Ejemplo n.º 2
0
    public IEnumerator Challenge(string opponent)
    {
        // wir brauchen eine Funktion, die getrennt von der Gamelogik läuft, da wir die Funktion Update anhalten müssen.
        // wird diese jedoch angehalten, kann man auch keine Knöpfe mehr drücken, also die Herausforderung nicht mehr akzeptieren/verneinen.

        YesOrNo.Instance.PopUp("You got challenged by: " + opponent, "Accept", "Decline");
        while (YesOrNo.Instance.Response == 0)
        {
            yield return(new WaitForEndOfFrame());
        }
        if (YesOrNo.Instance.Response == 1)
        {
            using (DarkRiftWriter writer = new DarkRiftWriter()) {
                writer.Write(opponent);
                Connection.SendMessageToServer((byte)TagsNSubjects.Tags.MATCHMAKING_TAG, (ushort)TagsNSubjects.MatchmakingSubjects.GAMESTART, writer);
            }
        }
        if (YesOrNo.Instance.Response == 2)
        {
            using (DarkRiftWriter writer = new DarkRiftWriter()) {
                Connection.SendMessageToServer((byte)TagsNSubjects.Tags.MATCHMAKING_TAG, (ushort)TagsNSubjects.MatchmakingSubjects.CHALLENGEDECLINED, writer);
            }
        }
    }
Ejemplo n.º 3
0
        public void TryLogin()
        {
            if (m_Connection.isConnected && IsLoginBtnInteractable)
            {
                IsLoginBtnInteractable = false;
                var payload = new GenericPayload <TryLoginRequestModel>
                {
                    Value = new TryLoginRequestModel
                    {
                        Username = Username,
                        Password = Password
                    }
                };

                m_Connection.SendMessageToServer((int)UsersPluginRequestTags.TryLoginRequest
                                                 , 0
                                                 , payload);
            }
        }