Пример #1
0
        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;
            }
        }
Пример #2
0
 public void LocationUpdate(VelocityMessage message)
 {
     // Forward a single messages to all browsers
     Clients.Group("BROWSERS").locationUpdate(message);
 }
Пример #3
0
 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;
 }