コード例 #1
0
ファイル: AuthResult.cs プロジェクト: BraZee/IgniteMe
 /// <summary>
 /// Parametered Constuctor
 /// </summary>
 /// <param name="success">Specifies whether the attempt successful was ok or not</param>
 /// <param name="extraMessage">Describes the the error message or additional info from the request response</param>
 /// <param name="returnCode">An enum for further descbing the _success </param>
 /// <param name="userToken">Token returned based on userId and authentication and security parameters</param>
 /// <param name="userFullName">Full name returned based on userId and authentication and security parameters</param>
 public AuthResult(bool success,
                   string extraMessage,
                   LoginReturn returnCode,
                   string userToken,
                   string userFullName)
 {
     _success = success;
     _extraMessage = extraMessage;
     _returnCode = returnCode;
     _userToken = userToken;
     _userFullName = userFullName;
 }
コード例 #2
0
ファイル: Socket.cs プロジェクト: Madslick/Pepper
    //-------------------------------------------------------------//
    // Convert from XML methods
    //-------------------------------------------------------------//
    public LoginReturn convertRecvToInfo(byte[] data, LoginReturn readInfo)
    {
        //decode binary data into readable string and passinto a string reader needed for XML Deserialzing
        string result = System.Text.Encoding.UTF8.GetString(data);
        StringReader stringReader = new StringReader(result);

        //create xml reader
        //XmlReaderSettings settings = new XmlReaderSettings();
        //Currently settings unsued, was needed before, leaving for refferrence (stringReader, settings)
        XmlReader xmlReader = XmlReader.Create(stringReader);

        //create xmlSerializer linked to type of class Info and deserialze string
        XmlSerializer xmlSerializer = new XmlSerializer(typeof(LoginReturn));
        readInfo = (LoginReturn)xmlSerializer.Deserialize(xmlReader);

        print (readInfo);
        print (readInfo.loggedIn);

        return readInfo;
    }
コード例 #3
0
ファイル: Socket.cs プロジェクト: Madslick/Pepper
    //-------------------------------------------------------------//
    // Read Message Methods
    //-------------------------------------------------------------//
    public void readSocket()
    {
        if (!socketReady && dataStream.DataAvailable)
            return;

        // read in message type and size of message
        int bytesNeeded = 4;
        byte[] messageType = new byte[bytesNeeded];
        byte[] lengthBuffer = new byte[bytesNeeded];

        messageType  = reader.ReadBytes(bytesNeeded);
        lengthBuffer = reader.ReadBytes(bytesNeeded);

        //convert bytes to littleEndian if needed
        if(BitConverter.IsLittleEndian) {

            Array.Reverse(messageType);
            Array.Reverse(lengthBuffer);
        }

        // convert bytes to int
        int type = BitConverter.ToInt32(messageType, 0);

        if(type == 1){

            LoginReturn readInfo = new LoginReturn();

            //should only be false if stream was closed before finished reading as bytereader is blocking
            if(lengthBuffer.Length == bytesNeeded) {

                int dataSize = BitConverter.ToInt32(lengthBuffer, 0);
                print(dataSize);

                byte[] data = new byte[dataSize];
                bytesNeeded = dataSize;
                data = reader.ReadBytes(dataSize);

                //convert data into usable class
                if(data.Length == bytesNeeded) {
                    readInfo = this.convertRecvToInfo(data, readInfo);
                }
            }

            if (readInfo.loggedIn == true) {
                Debug.Log("login success");
                this.displayText("Logged in!", true);

                maxTextTimer = 1f;
                closeToMenu = true;
            }
            else if (readInfo.loggedIn == false) {

                this.displayText("Unable to log in\nEmail or Password incorrect.", false);
                Debug.Log("unable to log in");
            }

            this.attemptRead = false;
        }
        else if(type == 2){
            //Sign up successful

            LoginReturn readInfo = new LoginReturn();

            //should only be false if stream was closed before finished reading as bytereader is blocking
            if(lengthBuffer.Length == bytesNeeded) {

                int dataSize = BitConverter.ToInt32(lengthBuffer, 0);
                print(dataSize);

                byte[] data = new byte[dataSize];
                bytesNeeded = dataSize;
                data = reader.ReadBytes(dataSize);

                //convert data into usable class
                if(data.Length == bytesNeeded) {
                    readInfo = this.convertRecvToInfo(data, readInfo);
                }
            }

            if (readInfo.loggedIn) {
                Debug.Log("sign up success");

                this.SwitchSignUp(false);
                this.displayText("Sign up successful.\n Logging in", false);
                this.sendLogin(1);
            }
            else if(!readInfo.loggedIn) {
                Debug.Log("unable to sign up");

                this.displayText("Unable to sign up\nEmail already exists", false);
                this.attemptRead = false;
            }
        }

        return;
    }