private void HandleResponsePacket <T>(APINetworkPacket genericPacket) where T : APINetworkPacket, IIdentifiable { var packet = genericPacket as T; var tcs = AcquireTcs <T>(packet.RequestId); tcs.TrySetResult(packet); }
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)); } }
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")); } }
private void HandleTradeUpdate(APINetworkPacket genericPacket) { var packet = (TradeUpdatePacket)genericPacket; OnTradeUpdate(packet); }
private void HandleTicksPacket(APINetworkPacket genericPacket) { var packet = (TickPacket)genericPacket; OnTicks(packet.Ticks); }
private void HandleMarginLevelPacket(APINetworkPacket genericPacket) { var packet = (MarginLevelPacket)genericPacket; OnMargin(packet.MarginLevel); }
public void SendPacket(APINetworkPacket packet) { SendPacket(serializer.SerializeWithHeader(packet)); }