本文整理汇总了C#中CIAPI.Rpc.Client.CreateStreamingClient方法的典型用法代码示例。如果您正苦于以下问题:C# Client.CreateStreamingClient方法的具体用法?C# Client.CreateStreamingClient怎么用?C# Client.CreateStreamingClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIAPI.Rpc.Client
的用法示例。
在下文中一共展示了Client.CreateStreamingClient方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupFixture
public void SetupFixture()
{
_rpcClient = BuildRpcClient();
_streamingClient = _rpcClient.CreateStreamingClient();
_CFDmarketId = GetAvailableCFDMarkets(_rpcClient)[0].MarketId;
_accounts = _rpcClient.AccountInformation.GetClientAndTradingAccount();
}
示例2: FixtureSetup
public override void FixtureSetup()
{
base.FixtureSetup();
// hmmmm... only one fixture setup allowed.
_rpcClient = BuildRpcClient();
_streamingClient = _rpcClient.CreateStreamingClient();
_CFDmarketId = MarketFixture.GetAvailableCFDMarkets(_rpcClient)[0].MarketId;
_accounts = _rpcClient.AccountInformation.GetClientAndTradingAccount();
}
示例3: Connect
public static void Connect()
{
Console.WriteLine ("Connecting to CIAPI");
_rpcClient = new Client(
new Uri(ConfigurationManager.AppSettings["Server"]),
new Uri(ConfigurationManager.AppSettings["StreamingServer"]),
ConfigurationManager.AppSettings["ApiKey"] );
_rpcClient.LogIn(ConfigurationManager.AppSettings["UserName"], ConfigurationManager.AppSettings["Password"]);
_streamingClient = _rpcClient.CreateStreamingClient();
}
示例4: DoPolling
private static void DoPolling()
{
var client = new Client(Const.RPC_URI, Const.STREAMING_URI, "Test.{B4E415A7-C453-4867-BDD1-C77ED345777B}");
try
{
client.LogIn(Const.USERNAME, Const.PASSWORD);
using (var streamingClient = client.CreateStreamingClient())
{
var topics = new[] { 99498, 99500 };
using (var pricesListener = streamingClient.BuildPricesListener(topics))
{
var finished = new ManualResetEvent(false);
pricesListener.MessageReceived +=
(s, e) =>
{
finished.Set();
Console.WriteLine("{0} -> {1}", e.Data.MarketId, e.Data.Price);
};
finished.WaitOne(10000);
streamingClient.TearDownListener(pricesListener);
}
}
client.LogOut();
}
catch (Exception exc)
{
Console.WriteLine(exc);
}
finally
{
try
{
client.Dispose();
}
catch (Exception exc)
{
Console.WriteLine(exc);
}
}
}
示例5: Execute
public override void Execute()
{
if (string.IsNullOrEmpty(ServerUrl))
throw new ApplicationException("StreamingLatencyMonitor: ServerUrl is not set");
lock (_sync)
{
if (_client == null)
{
_client = new Client(new Uri(ServerUrl), new Uri(StreamingServerUrl), "{API_KEY}", 1);
_client.LogIn(UserName, Password);
_streamingClient = _client.CreateStreamingClient();
_streamingStartTime = DateTime.UtcNow;
_listener = _streamingClient.BuildPricesListener(MarketId);
_listener.MessageReceived += OnPriceUpdate;
}
}
}
示例6: SetupFixture
public void SetupFixture()
{
_authenticatedClient = new Client(Settings.RpcUri, Settings.StreamingUri, AppKey);
_authenticatedClient.LogIn(Settings.RpcUserName, Settings.RpcPassword);
_streamingClient = _authenticatedClient.CreateStreamingClient();
}
示例7: ReturnsAnIStreamingClient
public void ReturnsAnIStreamingClient()
{
var rpcClient = new Client(new Uri("http://foo.com"), new Uri("http://foo.com"), "nullAndVoid");
Assert.IsInstanceOf(typeof(IStreamingClient), rpcClient.CreateStreamingClient());
}
示例8: CanStream
public void CanStream()
{
var server = new TestServer(true);
server.Start();
server.ProcessRequest += (s, e) =>
{
const string defaultPricesSessionid = "S8f295c055c413e4bT4448618";
switch (e.Request.Route)
{
// Streaming requests
case "/lightstreamer/create_session.txt":
// build up a session for adapter set
string response = string.Format(@"OK
SessionId:{0}
ControlAddress:localhost.
KeepaliveMillis:30000
MaxBandwidth:0.0
RequestLimit:50000
ServerName:Lightstreamer HTTP Server
PROBE
LOOP
", defaultPricesSessionid);
e.Response = TestServer.CreateLightStreamerResponse(response);
break;
case "/lightstreamer/control.txt":
// this is where we associate topics (tables) to a session
e.Response = TestServer.CreateLightStreamerResponse(@"OK
");
break;
case "/lightstreamer/bind_session.txt":
// this is where we return data. we can't use long polling with cassinidev
e.Response = TestServer.CreateLightStreamerResponse(string.Format(@"OK
SessionId:{0}
ControlAddress:localhost.
KeepaliveMillis:30000
MaxBandwidth:0.0
RequestLimit:50000
PROBE
1,5|#|#|#|#|#|#|#|#|#|#|#
1,1|sbPreProdFXAPP475974420|1.61793|-0.00114|1|1.62006|1.61737|400494226|1.61799|1.61796|0|\u005C/Date(1349422105265)\u005C/
1,4|sbPreProdFXAPP1416588099|0.93575|-0.00275|0|0.93892|0.93508|400494241|0.93603|0.93589|0|\u005C/Date(1349353115700)\u005C/
1,6|sbPreProdFXAPP475774416|1.21135|0.00019|1|1.21191|1.21109|400494215|1.21160|1.21147|0|\u005C/Date(1349422103923)\u005C/
1,7|sbPreProdFXAPP475974395|101.908|-0.245|1|102.279|101.863|400494220|101.929|101.918|0|\u005C/Date(1349422105171)\u005C/
1,8|sbPreProdFXAPP475774545|1.02494|0.00097|1|1.02746|1.02385|400494179|1.02513|1.02503|0|\u005C/Date(1349422104906)\u005C/
1,3|sbPreProdFXAPP475824759|1.610|-0.001|1|1.620|1.617|400494246|1.625|1.618|0|\u005C/Date(1349422105265)\u005C/
1,2|sbPreProdFXAPP475824757|1.61791|-0.00114|1|1.62006|1.61737|400494234|1.61801|1.61796|0|\u005C/Date(1349422105265)\u005C/
LOOP
", defaultPricesSessionid));
break;
default:
throw new Exception("unexpected request:" + e.Request.Route);
}
};
try
{
var ctx = new Client(new Uri("http://localhost.:" + server.Port), new Uri("http://localhost.:" + server.Port), "foo");
ctx.Session = "session";
ctx.UserName = "foo";
var streaming = ctx.CreateStreamingClient();
var listener = streaming.BuildDefaultPricesListener(9);
bool streamingMessageRecieved = false;
listener.MessageReceived += (a, r) =>
{
Console.WriteLine(r.Data.ToStringWithValues());
streamingMessageRecieved = true;
};
Thread.Sleep(3000);
//.........这里部分代码省略.........
示例9: BuildStreamingClient
public IStreamingClient BuildStreamingClient()
{
var authenticatedClient = new CIAPI.Rpc.Client(Settings.RpcUri, Settings.StreamingUri, AppKey);
authenticatedClient.LogIn(Settings.RpcUserName, Settings.RpcPassword);
return authenticatedClient.CreateStreamingClient();
}
示例10: GetPrice
private static PriceDTO GetPrice(Client client, int marketId)
{
var streamingClient = client.CreateStreamingClient();
var listener = streamingClient.BuildPricesListener(marketId);
PriceDTO price = null;
try
{
var finished = new ManualResetEvent(false);
listener.MessageReceived +=
(s, args) =>
{
price = args.Data;
finished.Set();
};
if (!finished.WaitOne(TimeSpan.FromMinutes(1)))
throw new ApplicationException("Can't obtain price: timed out");
return price;
}
finally
{
listener.Stop();
streamingClient.Dispose();
}
}
示例11: MockMultipleStreams
public void MockMultipleStreams()
{
// set up the server to mock responses so that we can utilize actual client instances for testing
var server = new TestServer(true);
try
{
server.Start();
server.ProcessRequest += (i, e) =>
{
if (e.Request.Route.StartsWith("/lightstreamer"))
{
ProcessStreamingRequest(e);
}
else
{
ProcessRpcRequest(e);
}
};
// now use the libraries as you normally would
var uri = new Uri("http://localhost.:" + server.Port);
var ctx = new Client(uri, uri, "foo");
var loginResponse = ctx.LogIn("foo", "bar");
// only difference here is that we MUST force polling mode on the lightstreamer client
var streamingClient = ctx.CreateStreamingClient();
var gates = new AutoResetEvent[] { new AutoResetEvent(false), new AutoResetEvent(false) };
bool defaultPricesListenerMessageRecieved = false;
bool pricesListenerMessageRecieved = false;
var defaultPricesListener = streamingClient.BuildDefaultPricesListener(9);
defaultPricesListener.MessageReceived += (a, r) =>
{
Console.WriteLine("\n***********************************\nDEFAULT PRICE\n***********************************\n");
defaultPricesListenerMessageRecieved = true;
gates[0].Set();
};
var pricesListener = streamingClient.BuildPricesListener(new[] { 99498, 99500 });
pricesListener.MessageReceived += (a, r) =>
{
Console.WriteLine("\n***********************************\nPRICE\n***********************************\n");
pricesListenerMessageRecieved = true;
gates[1].Set();
};
if(!WaitHandle.WaitAll(gates,20000))
{
throw new Exception("timed out waiting for events");
}
streamingClient.TearDownListener(defaultPricesListener);
streamingClient.TearDownListener(pricesListener);
streamingClient.Dispose();
ctx.LogOut();
ctx.Dispose();
}
finally
{
server.Stop();
}
}