Example #1
0
        private void HandleResponsePacket <T>(APINetworkPacket genericPacket) where T : APINetworkPacket, IIdentifiable
        {
            var packet = genericPacket as T;
            var tcs    = AcquireTcs <T>(packet.RequestId);

            tcs.TrySetResult(packet);
        }
Example #2
0
        private void HandlePacket(APINetworkPacket genericPacket)
        {
            var handler = packetHandlers[(int)genericPacket.Type];

            if (handler != null)
            {
                handler(genericPacket);
            }
        }
        private void OnPacketReceived(APINetworkPacket packet)
        {
            var h = PacketReceived;

            if (h != null)
            {
                EventHandler.RiseSafely(() => h(packet));
            }
        }
Example #4
0
        private void HandleLoginResponsePacket(APINetworkPacket genericPacket)
        {
            var packet = (LoginResponsePacket)genericPacket;
            var tcs    = AcquireTcs <LoginResponsePacket>(packet.RequestId);

            if (packet.LoginStatus == LoginStatus.Successful)
            {
                tcs.SetResult(packet);
            }
            else
            {
                tcs.SetException(new AuthenticationException("Authentication exception"));
            }
        }
Example #5
0
        private void HandleTradeUpdate(APINetworkPacket genericPacket)
        {
            var packet = (TradeUpdatePacket)genericPacket;

            OnTradeUpdate(packet);
        }
Example #6
0
        private void HandleTicksPacket(APINetworkPacket genericPacket)
        {
            var packet = (TickPacket)genericPacket;

            OnTicks(packet.Ticks);
        }
Example #7
0
        private void HandleMarginLevelPacket(APINetworkPacket genericPacket)
        {
            var packet = (MarginLevelPacket)genericPacket;

            OnMargin(packet.MarginLevel);
        }
 public void SendPacket(APINetworkPacket packet)
 {
     SendPacket(serializer.SerializeWithHeader(packet));
 }