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 LocationUpdate(VelocityMessage message) { // Forward a single messages to all browsers Clients.Group("BROWSERS").locationUpdate(message); }
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; }