public static void GetConcreteSerializer(
			SerializationContext context,
			PolymorphismSchema schema,
			Type abstractType,
			Type targetType,
			Type exampleType,
			out ICollectionInstanceFactory factory,
			out MessagePackSerializer serializer
		)
		{
			if ( abstractType == targetType )
			{
				throw SerializationExceptions.NewNotSupportedBecauseCannotInstanciateAbstractType( abstractType );
			}

			serializer = context.GetSerializer( targetType, schema );
			factory = serializer as ICollectionInstanceFactory;
			if ( factory == null && (serializer as IPolymorphicDeserializer) == null )
			{
				throw SerializationExceptions.NewIncompatibleCollectionSerializer( abstractType, serializer.GetType(), exampleType );
			}
		}
		public DateTimeOffsetMessagePackSerializerProvider( SerializationContext context, bool isNullable )
		{
			if ( isNullable )
			{
#if !UNITY
				this._unixEpoc =
					new NullableMessagePackSerializer<DateTimeOffset>( context, new DateTimeOffsetMessagePackSerializer( context, DateTimeConversionMethod.UnixEpoc ) );
				this._native =
					new NullableMessagePackSerializer<DateTimeOffset>( context, new DateTimeOffsetMessagePackSerializer( context, DateTimeConversionMethod.Native ) );
#else
				this._unixEpoc =
					new NullableMessagePackSerializer( context, typeof( DateTimeOffset? ), new DateTimeOffsetMessagePackSerializer( context, DateTimeConversionMethod.UnixEpoc ) );
				this._native =
					new NullableMessagePackSerializer( context, typeof( DateTimeOffset? ), new DateTimeOffsetMessagePackSerializer( context, DateTimeConversionMethod.Native ) );
#endif // !UNITY
			}
			else
			{
				this._unixEpoc = new DateTimeOffsetMessagePackSerializer( context, DateTimeConversionMethod.UnixEpoc );
				this._native = new DateTimeOffsetMessagePackSerializer( context, DateTimeConversionMethod.Native );
			}
		}
		public DateTimeMessagePackSerializerProvider( SerializationContext context, bool isNullable )
		{
			if ( isNullable )
			{
#if !UNITY
				this._unixEpoc =
					new NullableMessagePackSerializer<DateTime>( context, new UnixEpocDateTimeMessagePackSerializer( context ) );
				this._native =
					new NullableMessagePackSerializer<DateTime>( context, new NativeDateTimeMessagePackSerializer( context ) );
#else
				this._unixEpoc =
					new NullableMessagePackSerializer( context, typeof( DateTime? ), new UnixEpocDateTimeMessagePackSerializer( context ) );
				this._native =
					new NullableMessagePackSerializer( context, typeof( DateTime? ), new NativeDateTimeMessagePackSerializer( context ) );
#endif // !UNITY
			}
			else
			{
				this._unixEpoc = new UnixEpocDateTimeMessagePackSerializer( context );
				this._native = new NativeDateTimeMessagePackSerializer( context );
			}
		}
예제 #4
0
 private static void Flush()
 {
     File.WriteAllBytes(Filename, MessagePackSerializer.Serialize(Variables));
 }
예제 #5
0
        T Convert <T>(T value)
        {
            var resolver = new WithRxPropDefaultResolver();

            return(MessagePackSerializer.Deserialize <T>(MessagePackSerializer.Serialize(value, resolver), resolver));
        }
예제 #6
0
 string JsonConvert(string json)
 {
     return(MessagePackSerializer.ToJson(MessagePackSerializer.FromJson(json)));
 }
예제 #7
0
 /// <summary>
 /// Parses a state update from a byte[]
 /// </summary>
 /// <param name="b">byte[] to parse</param>
 /// <returns>The represented StateUpdate</returns>
 public static StateUpdate FromBytes(byte[] b)
 {
     return(MessagePackSerializer.Deserialize <StateUpdate>(b));
 }
예제 #8
0
        // Receive from udp socket and push value to subscribers.
        async void RunReceiveLoop(Stream pipeStream, Func <CancellationToken, Task>?waitForConnection)
        {
RECONNECT:
            var token = cancellationTokenSource.Token;

            if (waitForConnection != null)
            {
                try
                {
                    await waitForConnection(token).ConfigureAwait(false);
                }
                catch (IOException)
                {
                    return; // connection closed.
                }
            }
            var buffer = new byte[65536];

            while (!token.IsCancellationRequested)
            {
                ReadOnlyMemory <byte> value = Array.Empty <byte>();
                try
                {
                    var readLen = await pipeStream.ReadAsync(buffer, 0, buffer.Length, token).ConfigureAwait(false);

                    if (readLen == 0)
                    {
                        if (waitForConnection != null)
                        {
                            server.Value.Dispose();
                            server     = CreateLazyServerStream();
                            pipeStream = server.Value;
                            goto RECONNECT; // end of stream(disconnect, wait reconnect)
                        }
                    }

                    var messageLen = MessageBuilder.FetchMessageLength(buffer);
                    if (readLen == (messageLen + 4))
                    {
                        value = buffer.AsMemory(4, messageLen); // skip length header
                    }
                    else
                    {
                        // read more
                        if (buffer.Length < (messageLen + 4))
                        {
                            Array.Resize(ref buffer, messageLen + 4);
                        }
                        var remain = messageLen - (readLen - 4);
                        await ReadFullyAsync(buffer, pipeStream, readLen, remain, token).ConfigureAwait(false);

                        value = buffer.AsMemory(4, messageLen);
                    }
                }
                catch (IOException)
                {
                    return; // connection closed.
                }
                catch (Exception ex)
                {
                    if (ex is OperationCanceledException)
                    {
                        return;
                    }
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }

                    // network error, terminate.
                    options.UnhandledErrorHandler("network error, receive loop will terminate." + Environment.NewLine, ex);
                    return;
                }

                try
                {
                    var message = MessageBuilder.ReadPubSubMessage(value.ToArray()); // can avoid copy?
                    switch (message.MessageType)
                    {
                    case MessageType.PubSub:
                        publisher.Publish(message, message, CancellationToken.None);
                        break;

                    case MessageType.RemoteRequest:
                    {
                        // NOTE: should use without reflection(Expression.Compile)
                        var header = Deserialize <RequestHeader>(message.KeyMemory, options.MessagePackSerializerOptions);
                        var(mid, reqTypeName, resTypeName) = (header.MessageId, header.RequestType, header.ResponseType);
                        byte[] resultBytes;
                        try
                        {
                            var t                 = AsyncRequestHandlerRegistory.Get(reqTypeName, resTypeName);
                            var interfaceType     = t.GetInterfaces().First(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandler"));
                            var coreInterfaceType = t.GetInterfaces().First(x => x.IsGenericType && x.Name.StartsWith("IAsyncRequestHandlerCore"));
                            var service           = provider.GetRequiredService(interfaceType); // IAsyncRequestHandler<TRequest,TResponse>
                            var genericArgs       = interfaceType.GetGenericArguments();        // [TRequest, TResponse]
                            var request           = MessagePackSerializer.Deserialize(genericArgs[0], message.ValueMemory, options.MessagePackSerializerOptions);
                            var responseTask      = coreInterfaceType.GetMethod("InvokeAsync") !.Invoke(service, new[] { request, CancellationToken.None });
                            var task              = typeof(ValueTask <>).MakeGenericType(genericArgs[1]).GetMethod("AsTask") !.Invoke(responseTask, null);
                            await((System.Threading.Tasks.Task)task !);         // Task<T> -> Task
                            var result = task.GetType().GetProperty("Result") !.GetValue(task);
                            resultBytes = MessageBuilder.BuildRemoteResponseMessage(mid, genericArgs[1], result !, options.MessagePackSerializerOptions);
                        }
                        catch (Exception ex)
                        {
                            // NOTE: ok to send stacktrace?
                            resultBytes = MessageBuilder.BuildRemoteResponseError(mid, ex.ToString(), options.MessagePackSerializerOptions);
                        }

                        await pipeStream.WriteAsync(resultBytes, 0, resultBytes.Length).ConfigureAwait(false);
                    }
                    break;

                    case MessageType.RemoteResponse:
                    case MessageType.RemoteError:
                    {
                        var mid = Deserialize <int>(message.KeyMemory, options.MessagePackSerializerOptions);
                        if (responseCompletions.TryRemove(mid, out var tcs))
                        {
                            if (message.MessageType == MessageType.RemoteResponse)
                            {
                                tcs.TrySetResult(message);         // synchronous completion, use memory buffer immediately.
                            }
                            else
                            {
                                var errorMsg = MessagePackSerializer.Deserialize <string>(message.ValueMemory, options.MessagePackSerializerOptions);
                                tcs.TrySetException(new RemoteRequestException(errorMsg));
                            }
                        }
                    }
                    break;

                    default:
                        break;
                    }
                }
                catch (IOException)
                {
                    return; // connection closed.
                }
                catch (Exception ex)
                {
                    if (ex is OperationCanceledException)
                    {
                        continue;
                    }
                    options.UnhandledErrorHandler("", ex);
                }
            }
        }
예제 #9
0
        public async Task ParseMessage(byte[] message)
        {
            try
            {
                var baseDto = MessagePackSerializer.Deserialize <BinaryDtoBase>(message);

                switch (baseDto.DtoType)
                {
                case BinaryDtoType.MouseMove:
                case BinaryDtoType.MouseDown:
                case BinaryDtoType.MouseUp:
                case BinaryDtoType.Tap:
                case BinaryDtoType.MouseWheel:
                case BinaryDtoType.KeyDown:
                case BinaryDtoType.KeyUp:
                case BinaryDtoType.CtrlAltDel:
                case BinaryDtoType.ToggleBlockInput:
                case BinaryDtoType.ClipboardTransfer:
                case BinaryDtoType.KeyPress:
                {
                    if (!Viewer.HasControl)
                    {
                        return;
                    }
                }
                break;

                default:
                    break;
                }

                switch (baseDto.DtoType)
                {
                case BinaryDtoType.SelectScreen:
                    SelectScreen(message);
                    break;

                case BinaryDtoType.MouseMove:
                    MouseMove(message);
                    break;

                case BinaryDtoType.MouseDown:
                    MouseDown(message);
                    break;

                case BinaryDtoType.MouseUp:
                    MouseUp(message);
                    break;

                case BinaryDtoType.Tap:
                    Tap(message);
                    break;

                case BinaryDtoType.MouseWheel:
                    MouseWheel(message);
                    break;

                case BinaryDtoType.KeyDown:
                    KeyDown(message);
                    break;

                case BinaryDtoType.KeyUp:
                    KeyUp(message);
                    break;

                case BinaryDtoType.CtrlAltDel:
                    await CasterSocket.SendCtrlAltDel();

                    break;

                case BinaryDtoType.AutoQualityAdjust:
                    SetAutoQualityAdjust(message);
                    break;

                case BinaryDtoType.ToggleAudio:
                    ToggleAudio(message);
                    break;

                case BinaryDtoType.ToggleBlockInput:
                    ToggleBlockInput(message);
                    break;

                case BinaryDtoType.ClipboardTransfer:
                    ClipboardTransfer(message);
                    break;

                case BinaryDtoType.KeyPress:
                    await KeyPress(message);

                    break;

                case BinaryDtoType.QualityChange:
                    QualityChange(message);
                    break;

                case BinaryDtoType.File:
                    await DownloadFile(message);

                    break;

                case BinaryDtoType.WindowsSessions:
                    await GetWindowsSessions();

                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
            }
        }
예제 #10
0
        private void ToggleAudio(byte[] message)
        {
            var dto = MessagePackSerializer.Deserialize <ToggleAudioDto>(message);

            AudioCapturer.ToggleAudio(dto.ToggleOn);
        }
 protected override void Encode(IChannelHandlerContext context, object message, IByteBuffer output)
 {
     byte[] temp = MessagePackSerializer.Serialize(message);
     output.WriteBytes(temp);
 }
예제 #12
0
 public MemoryKeyMemoryTest()
 {
     MessagePackSerializer.SetDefaultResolver(MessagePackResolver.Instance);
 }
예제 #13
0
 public static void Send <T>(this NetPeer peer, T message, DeliveryMethod method = DeliveryMethod.ReliableOrdered) where T : Message
 {
     peer.Send(MessagePackSerializer.Serialize(message as Message), method);
 }
예제 #14
0
    void LobbyHandler(byte[] data)
    {
        LobbyObj lobbyObj = MessagePackSerializer.Deserialize <LobbyObj>(data);

        if (!applyPlayerSelectObj && playerSelectObj == null)
        {
            playerSelectObj = lobbyObj.PeerSelectObj;
            if (state == SceneState.Lobby)
            {
                type = playerSelectObj.Type;
                SetUnitTypeIcon(type);

                _name = playerSelectObj.Name;
                nameInputField.text = playerSelectObj.Name;

                _team = playerSelectObj.Team;
                SetTeamButtonColor(_team);

                _ready = playerSelectObj.Ready;
                SetReadyButtonColor(_ready);

                applyPlayerSelectObj = true;
                playerSelectObj      = null;
            }
        }

        if (state == SceneState.Lobby)
        {
            if (lobbyObj.State == 0)
            {
                lobbyTitle.text = "Before Battle";
            }
            else if (lobbyObj.State == 1)
            {
                lobbyTitle.text = lobbyObj.Timer.ToString("F0");
            }
            else
            {
                lobbyTitle.text = "In Battle";
            }

            bluePlayerNodeInstances.ForEach(x => Destroy(x));
            bluePlayerNodeInstances.Clear();
            redPlayerNodeInstances.ForEach(x => Destroy(x));
            redPlayerNodeInstances.Clear();

            foreach (SelectObj selectObj in lobbyObj.SelectObjs)
            {
                if (selectObj.Team == Team.Blue)
                {
                    GameObject instance = Instantiate(playerNodePrefab, blueContentRectTransform);
                    instance.GetComponent <PlayerNode>().SetData(selectObj.Type, selectObj.Team, selectObj.Name, selectObj.Ready);
                    bluePlayerNodeInstances.Add(instance);
                }
                else
                {
                    GameObject instance = Instantiate(playerNodePrefab, redContentRectTransform);
                    instance.GetComponent <PlayerNode>().SetData(selectObj.Type, selectObj.Team, selectObj.Name, selectObj.Ready);
                    redPlayerNodeInstances.Add(instance);
                }
            }
        }
        else if (state == SceneState.Main)
        {
            SceneManager.LoadScene("Lobby");
        }
    }
예제 #15
0
 public byte[] Serialize <TStruct>(ref TStruct item)
 {
     return(UseLZ4 ? LZ4MessagePackSerializer.Serialize(item, Resolver) :
            MessagePackSerializer.Serialize(item, Resolver));
 }
예제 #16
0
 public TStruct Deserialize <TStruct>(byte[] serialized)
 {
     return(UseLZ4 ? LZ4MessagePackSerializer.Deserialize <TStruct>(serialized, Resolver) :
            MessagePackSerializer.Deserialize <TStruct>(serialized, Resolver));
 }
예제 #17
0
        private void SelectScreen(byte[] message)
        {
            var dto = MessagePackSerializer.Deserialize <SelectScreenDto>(message);

            Viewer.Capturer.SetSelectedScreen(dto.DisplayName);
        }
예제 #18
0
        private void SetAutoQualityAdjust(byte[] message)
        {
            var dto = MessagePackSerializer.Deserialize <AutoQualityAdjustDto>(message);

            Viewer.AutoAdjustQuality = dto.IsOn;
        }
 public object Deserialize(byte[] data, Type type)
 {
     return(data == null ? null : MessagePackSerializer.Deserialize(type, data));
 }
예제 #20
0
        private void ToggleBlockInput(byte[] message)
        {
            var dto = MessagePackSerializer.Deserialize <ToggleBlockInputDto>(message);

            KeyboardMouseInput.ToggleBlockInput(dto.ToggleOn);
        }
 public object DeserializeNoType(byte[] data, Type type)
 {
     return(data == null
         ? null
         : MessagePackSerializer.Deserialize(type, data, ContractlessStandardResolver.Options));
 }
예제 #22
0
        internal static void PackCollectionCore <T>(Packer source, IEnumerable <T> collection, MessagePackSerializer <T> itemSerializer)
        {
            // ReSharper disable once CompareNonConstrainedGenericWithNull
            if (collection == null)
            {
                source.PackNull();
                return;
            }

            // ReSharper disable once SuspiciousTypeConversion.Global
            var asPackable = collection as IPackable;

            if (asPackable != null)
            {
                asPackable.PackToMessage(source, new PackingOptions());
                return;
            }

            int             count;
            ICollection <T> asCollectionT;
            ICollection     asCollection;

            if ((asCollectionT = collection as ICollection <T>) != null)
            {
                count = asCollectionT.Count;
            }
            else if ((asCollection = collection as ICollection) != null)
            {
                count = asCollection.Count;
            }
            else
            {
                var asArray = collection.ToArray();
                count      = asArray.Length;
                collection = asArray;
            }

            source.PackArrayHeader(count);
            foreach (var item in collection)
            {
                itemSerializer.PackTo(source, item);
            }
        }
 T Convert <T>(T value)
 {
     return(MessagePackSerializer.Deserialize <T>(MessagePackSerializer.Serialize(value, options), options));
 }
예제 #24
0
 /// <summary>
 /// Serializes the state update to bytes
 /// </summary>
 /// <returns>The serialized byte[]</returns>
 public byte[] ToBytes()
 {
     return(MessagePackSerializer.Serialize(this));
 }
예제 #25
0
        private void KeyUp(byte[] message)
        {
            var dto = MessagePackSerializer.Deserialize <KeyUpDto>(message);

            KeyboardMouseInput.SendKeyUp(dto.Key, Viewer);
        }
예제 #26
0
        public void AllowPrivate()
        {
            {
                var p = new HasPrivate {
                    PublicKey = 100, PublicKeyS = "foo"
                };
                p.SetPrivate(99, "bar");

                var bin  = MessagePackSerializer.Serialize(p, MessagePack.Resolvers.StandardResolverAllowPrivate.Instance);
                var json = MessagePackSerializer.ToJson(bin);

                json.Is("[99,100,\"bar\",\"foo\"]");

                var r2 = MessagePackSerializer.Deserialize <HasPrivate>(bin, MessagePack.Resolvers.StandardResolverAllowPrivate.Instance);
                r2.PublicKey.Is(100);
                r2.PublicKeyS.Is("foo");
                r2.GetPrivateInt().Is(99);
                r2.GetPrivateStr().Is("bar");
            }
            {
                var p = new HasPrivateStruct {
                    PublicKey = 100, PublicKeyS = "foo"
                };
                p.SetPrivate(99, "bar");

                var bin  = MessagePackSerializer.Serialize(p, MessagePack.Resolvers.StandardResolverAllowPrivate.Instance);
                var json = MessagePackSerializer.ToJson(bin);

                json.Is("[99,100,\"bar\",\"foo\"]");

                var r2 = MessagePackSerializer.Deserialize <HasPrivate>(bin, MessagePack.Resolvers.StandardResolverAllowPrivate.Instance);
                r2.PublicKey.Is(100);
                r2.PublicKeyS.Is("foo");
                r2.GetPrivateInt().Is(99);
                r2.GetPrivateStr().Is("bar");
            }
            {
                var p = new HasPrivateStringKey {
                    PublicKey = 100, PublicKeyS = "foo"
                };
                p.SetPrivate(99, "bar");

                var bin  = MessagePackSerializer.Serialize(p, MessagePack.Resolvers.StandardResolverAllowPrivate.Instance);
                var json = MessagePackSerializer.ToJson(bin);

                json.Is("{\"PublicKey\":100,\"privateKeyS\":\"bar\",\"PublicKeyS\":\"foo\",\"privateKey\":99}");

                var r2 = MessagePackSerializer.Deserialize <HasPrivateStringKey>(bin, MessagePack.Resolvers.StandardResolverAllowPrivate.Instance);
                r2.PublicKey.Is(100);
                r2.PublicKeyS.Is("foo");
                r2.GetPrivateInt().Is(99);
                r2.GetPrivateStr().Is("bar");
            }
            {
                var p = new HasPrivateContractless {
                    PublicKey = 100, PublicKeyS = "foo"
                };
                p.SetPrivate(99, "bar");

                var bin  = MessagePackSerializer.Serialize(p, MessagePack.Resolvers.ContractlessStandardResolverAllowPrivate.Instance);
                var json = MessagePackSerializer.ToJson(bin);

                json.Is("{\"PublicKey\":100,\"privateKeyS\":\"bar\",\"PublicKeyS\":\"foo\",\"privateKey\":99}");

                var r2 = MessagePackSerializer.Deserialize <HasPrivateContractless>(bin, MessagePack.Resolvers.ContractlessStandardResolverAllowPrivate.Instance);
                r2.PublicKey.Is(100);
                r2.PublicKeyS.Is("foo");
                r2.GetPrivateInt().Is(99);
                r2.GetPrivateStr().Is("bar");
            }
        }
예제 #27
0
        private void MouseMove(byte[] message)
        {
            var dto = MessagePackSerializer.Deserialize <MouseMoveDto>(message);

            KeyboardMouseInput.SendMouseMove(dto.PercentX, dto.PercentY, Viewer);
        }
예제 #28
0
 private T Convert <T>(T value)
 {
     return(MessagePackSerializer.Deserialize <T>(MessagePackSerializer.Serialize(value)));
 }
예제 #29
0
        public SerializeBenchmark()
        {
            book = new Book();
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, IsTip = false, OpenQuantity = 1000, OrderCondition = OrderCondition.None, OrderId = 3434, Price = 234, Quantity = 1000, StopPrice = 0, TotalQuantity = 0
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, IsTip = false, OpenQuantity = 1000, OrderCondition = OrderCondition.None, OrderId = 3434, Price = 235, Quantity = 1000, StopPrice = 0, TotalQuantity = 0
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, IsTip = false, OpenQuantity = 1000, OrderCondition = OrderCondition.None, OrderId = 3435, Price = 236, Quantity = 1000, StopPrice = 0, TotalQuantity = 0
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, IsTip = false, OpenQuantity = 1000, OrderCondition = OrderCondition.None, OrderId = 3436, Price = 237, Quantity = 1000, StopPrice = 0, TotalQuantity = 0
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, IsTip = false, OpenQuantity = 1000, OrderCondition = OrderCondition.None, OrderId = 3437, Price = 238, Quantity = 1000, StopPrice = 0, TotalQuantity = 0
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, IsTip = false, OpenQuantity = 1000, OrderCondition = OrderCondition.None, OrderId = 3438, Price = 239, Quantity = 1000, StopPrice = 0, TotalQuantity = 0
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, IsTip = false, OpenQuantity = 1000, OrderCondition = OrderCondition.None, OrderId = 3439, Price = 240, Quantity = 1000, StopPrice = 0, TotalQuantity = 0
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, IsTip = false, OpenQuantity = 1000, OrderCondition = OrderCondition.None, OrderId = 3440, Price = 241, Quantity = 1000, StopPrice = 0, TotalQuantity = 0
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, IsTip = false, OpenQuantity = 1000, OrderCondition = OrderCondition.None, OrderId = 3441, Price = 242, Quantity = 1000, StopPrice = 0, TotalQuantity = 0
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, IsTip = false, OpenQuantity = 1000, OrderCondition = OrderCondition.None, OrderId = 3442, Price = 243, Quantity = 1000, StopPrice = 0, TotalQuantity = 0
            });
            bid = book.BidSide.Select(x => new KeyValuePair <Price, Quantity>(x.Key, x.Value.Quantity)).ToList();
            ask = book.AskSide.Select(x => new KeyValuePair <Price, Quantity>(x.Key, x.Value.Quantity)).ToList();


            orderJsonString = JsonConvert.SerializeObject(new Order {
                CancelOn = 12345678, IsBuy = true, OrderCondition = OrderCondition.ImmediateOrCancel, OrderId = 56789, Price = 404, Quantity = 2356, StopPrice = 9534, TotalQuantity = 7878234
            });
            orderBinarySerialized = OrderSerializer.Serialize(new Order {
                CancelOn = 12345678, IsBuy = true, OrderCondition = OrderCondition.ImmediateOrCancel, OrderId = 56789, Price = 404, Quantity = 2356, StopPrice = 9534, TotalQuantity = 7878234
            });
            orderMsgPck = MessagePackSerializer.Serialize(new Order2 {
                IsBuy = true, IsTip = false, OpenQuantity = 100, OrderCondition = OrderCondition.None, OrderId = 1001, Price = 400, Quantity = 100, Sequnce = 0, StopPrice = 0
            });

            fillJsonString = JsonConvert.SerializeObject(new Fill {
                MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
            });
            fillBinary = FillSerializer.Serialize(new Fill {
                MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
            });

            cancelJsonString = JsonConvert.SerializeObject(new CancelledOrder {
                OrderId = 1201, CancelReason = CancelReason.UserRequested, RemainingQuantity = 2000, Timestamp = 234
            });
            cancelBinary = CancelledOrderSerializer.Serialize(new CancelledOrder {
                OrderId = 1201, CancelReason = CancelReason.UserRequested, RemainingQuantity = 2000, Timestamp = 234
            });

            cancelRequestJsonString = JsonConvert.SerializeObject(new CancelRequest {
                OrderId = 1023
            });
            cancelRequestBinary = CancelRequestSerializer.Serialize(new CancelRequest {
                OrderId = 1023
            });

            orderTriggerBinary = OrderTriggerSerializer.Serialize(new OrderTrigger {
                OrderId = 3453, Timestamp = 35345
            });
            orderTriggerJsonString = JsonConvert.SerializeObject(new OrderTrigger {
                OrderId = 3453, Timestamp = 35345
            });

            bookRequestBinary     = BookRequestSerializer.Serialize(new BookRequest {
            });
            bookRequestJsonString = JsonConvert.SerializeObject(new BookRequest {
            });
            bookRequest2          = MessagePackSerializer.Serialize(new BookRequest2 {
            });

            bookJsonString = JsonConvert.SerializeObject(new BookDepth {
                Bid = bid, Ask = ask, LTP = 100, TimeStamp = 1234
            });
            bookBinary = BookSerializer.Serialize(book, 5, 100, 1234);
        }
예제 #30
0
        private void MouseWheel(byte[] message)
        {
            var dto = MessagePackSerializer.Deserialize <MouseWheelDto>(message);

            KeyboardMouseInput.SendMouseWheel(-(int)dto.DeltaY, Viewer);
        }
예제 #31
0
 public void bookRequestMsgPckSerialize()
 {
     var msg = MessagePackSerializer.Serialize(new BookRequest2 {
     });
 }
예제 #32
0
        private void QualityChange(byte[] message)
        {
            var dto = MessagePackSerializer.Deserialize <QualityChangeDto>(message);

            Viewer.ImageQuality = dto.QualityLevel;
        }
예제 #33
0
 public void orderMsgPckSerialize()
 {
     var msgPck = MessagePackSerializer.Serialize(new Order2 {
         IsBuy = true, IsTip = false, OpenQuantity = 100, OrderCondition = OrderCondition.None, OrderId = 1001, Price = 400, Quantity = 100, Sequnce = 0, StopPrice = 0
     });
 }