Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyHub : Hub
- {
- public override Task OnConnectedAsync()
- {
- Observable.Interval(TimeSpan.FromSeconds(0.5)).Subscribe(l =>
- {
- var alt = CalcAltitude(l);
- SendMessage(alt);
- });
- return Task.CompletedTask;
- }
- private void SendMessage(double alt)
- {
- Clients.All.SendAsync("SendAction", new Status() {Altitude = alt});
- }
- private double CalcAltitude(long l)
- {
- return 100 * Math.Sin((double) l / 100) + 200;
- }
- }
- public class Status
- {
- public double Altitude { get; set; }
- }
- var hubContext = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
- hubContext.Clients.All.SendnewData(Data);
Add Comment
Please, Sign In to add comment