Example #1
0
    public void VerifyResponse(NetWorker networker, NetworkingPlayer player, BMSByte response, System.Action <NetworkingPlayer> authUserAction, System.Action <NetworkingPlayer> rejectUserAction)
    {
        uint id;

        switch (status)
        {
        case Server.AuthStatus.Available:
            id = response.GetBasicType <uint>();

            BinaryFormatter binFor    = new BinaryFormatter();
            MemoryStream    memStream = new MemoryStream();

            byte[] bytes = response.GetByteArray(sizeof(uint));
            memStream.Write(bytes, 0, bytes.Length);
            memStream.Position = 0;

            List <uint> ids = binFor.Deserialize(memStream) as List <uint>;

            if (ids.Contains(id))
            {
                ids.Remove(id);
                authUserAction(player);
                status     = Server.AuthStatus.Checking;
                allowedIds = ids;
            }
            else
            {
                rejectUserAction(player);
            }

            //uint[] ids = ObjectMapper.Instance.Map<uint[]>(response);
            break;

        case Server.AuthStatus.Checking:
            id = response.GetBasicType <uint>();
            if (allowedIds.Contains(id))
            {
                authUserAction(player);
                allowedIds.Remove(id);
            }
            else
            {
                rejectUserAction(player);
            }
            return;

        case Server.AuthStatus.Closed:
            rejectUserAction(player);
            return;
        }
    }