Beispiel #1
0
    public void LoadFromCode()
    {
        string inp = InputCode.GetComponent <InputField> ().text;

        LoadSharing(StringCompressor.Decompress(inp));
        HideLoadFromPanel();
        HideLoadDialoge();
    }
Beispiel #2
0
    public void Share()
    {
        string buf = StringCompressor.Compress(SaveSharing());

        print(buf);
        print(StringCompressor.Decompress(buf));
        StartCoroutine(ShareAndRate.ShareAndroidText(buf));
    }
Beispiel #3
0
        public void Decompress_WhenGivenCompressedString_ReturnsOriginalUncompressedString()
        {
            // Act
            var compressedJson   = _stringCompressor.Compress(TestJson);
            var decompressedJson = _stringCompressor.Decompress(compressedJson);

            // Assert
            decompressedJson.Should().Be(TestJson);
        }
        public void 압축_테스트()
        {
            const String ORIGIN_TEXT = "Test text..... test test test !!!!!!!!!!! 1234567890";

            String compressed = StringCompressor.Compress(ORIGIN_TEXT);

            String decompressed = StringCompressor.Decompress(compressed);

            Assert.IsTrue(decompressed == ORIGIN_TEXT);

            Assert.IsTrue(StringCompressor.Compress(null) == String.Empty);

            Assert.IsTrue(StringCompressor.Decompress(null) == String.Empty);
        }
Beispiel #5
0
        public static object Decode(IBinaryInputStream data)
        {
            byte type = data.ReadByte();

            switch (type)
            {
            case 42:
                return(new LowLevelConnectMessage());

            case APlayCodec.MSGTYPE_PAYLOAD:
                APlayStringMessage msg = new APlayStringMessage();
                msg.SetDataAsString(data.ReadString());
                return(msg);

            case APlayCodec.MSGTYPE_PAYLOAD_BINARY_JSON:
                GameContext.Logger.LogDebug($"Package [MSGTYPE_PAYLOAD_BINARY_JSON] received: {data.ReadInt()} byte(s)");

                APlayStringMessage msg2 = new APlayStringMessage();
                msg2.SetDataAsJson(APlayBinaryMessage.ReadJsonEncoded(data));
                return(msg2);

            case APlayCodec.MSGTYPE_PAYLOAD_GZIP:     // this even used?
                APlayStringMessage msg3 = new APlayStringMessage();
                msg3.SetDataAsString(StringCompressor.Decompress(data.ReadBytes()));
                return(msg3);

            case APlayCodec.MSGTYPE_LOWLEVEL_PING:
                GameContext.Logger.LogDebug($"Package [MSGTYPE_LOWLEVEL_PING] received: {data.ReadInt()} byte(s)");

                return(new LowLevelPingMessage {
                    PingTime = data.ReadLong(),
                    LastRTT = data.ReadInt()
                });

            case APlayCodec.MSGTYPE_LOWLEVEL_PONG:
                GameContext.Logger.LogDebug($"Package [MSGTYPE_LOWLEVEL_PONG] received: {data.ReadInt()} byte(s)");

                return(new LowLevelPongMessage {
                    PingTime = data.ReadLong()
                });

            case APlayCodec.MSGTYPE_LOWLEVEL_INTRODUCTION:
                return(new LowLevelIntroductionMessage {
                    AddressString = data.ReadString()
                });
            }
            return(null);
        }
Beispiel #6
0
        public static object DeSerializeDataStructure(string serializationString)
        {
            byte[]           serializationData = Convert.FromBase64String(serializationString);
            MemoryStream     ms        = new MemoryStream();
            MemoryStream     ms2       = new MemoryStream();
            StringCompressor sc        = new StringCompressor();
            BinaryFormatter  formatter = new BinaryFormatter();

            try
            {
                ms.Write(serializationData, 0, serializationData.Length);
                sc.Decompress(ms, ms2);
                ms2.Position = 0;

                return(formatter.Deserialize(ms2));
            }
            catch { return(null); }
        }