public Task SendMessage(VelocityMessage message) { // add a message to the send queue messageQueue.Add(message); if (messageQueue.Count > 25) { // if the queue size is greater than 25, flush the queue Flush(); } return(TaskDone.Done); }
public async Task ProcessMessage(DeviceMessage message) { if (_lastMessage is null || _lastMessage.Latitude != message.Latitude || _lastMessage.Longitude != message.Longitude) { // Only sent a notification if the position has changed var notifier = GrainFactory.GetGrain <IPushNotifierGrain>(0); var speed = GetSpeed(_lastMessage, message); // Record the last message _lastMessage = message; // Forward the message to the notifier grain var velocityMessage = new VelocityMessage(message, speed); await notifier.SendMessage(velocityMessage); }
public async Task ProcessMessage(DeviceMessage message) { if (null == this.LastMessage || this.LastMessage.Latitude != message.Latitude || this.LastMessage.Longitude != message.Longitude) { // only sent a notification if the position has changed var notifier = GrainFactory.GetGrain <IPushNotifierGrain>(0); var speed = GetSpeed(this.LastMessage, message); // record the last message this.LastMessage = message; // forward the message to the notifier grain var velocityMessage = new VelocityMessage(message, speed); await notifier.SendMessage(velocityMessage); } else { // the position has not changed, just record the last message this.LastMessage = message; } }
public void OnVelocityMessage(VelocityMessage velocityMessage) { pilotApi.SetPower(SafePower); }
public void LocationUpdate(VelocityMessage message) { // Forward a single messages to all browsers Clients.Group("BROWSERS").locationUpdate(message); }