Building a Real-time Push App with Silverlight: Part 7
2011-09-16

Infrastructure Refactor A lot of things changed internally, and I mean….a lot…. From an infrastructure standpoint, I decided to remove the dependency on LinqToTwitter, and I replaced it with Hammock.  A couple things led me to this decision, one being the Silverlight support wasn’t as good as I’d hoped, and the streaming API implementation was limited.  After reading the Twitter documentation I realized that the REST API was super simple and I’d be better off writing a simple interface to it. Read on...
Building a Real-time Push App with Silverlight: Part 6
2011-09-13

Back to the UI! For this post I’m going to restyle the tweets. Recall that they currently look like this: The gradient background is currently #FFEEEEEE to #FFDDDDDD. For this post I’m going to talk about a very powerful tool in a designer’s arsenal: transparency. Your first may be to think “big deal”, but just like programmers can use base classes and injection to share common code, designers can use transparency to achieve a similar effect. Read on...
Building a Real-time Push App with Silverlight: Part 5
2011-09-08

I planned on this post to be about UI, but I’m going to defer that until the next post. I said from the start of this series that I would document about everything about building the application from scratch, including my struggles. And with that I want to mention something that got me scratching my head one too many times. It was with how I used LinqToTwitter. Here is the source code which you can immediately copy/paste into a blank project to reproduce: public partial class MainPage : UserControl { private readonly TwitterContext _context = new TwitterContext(); private readonly ViewModel _vm1, _vm2, _vm3; public MainPage() { InitializeComponent(); _vm1 = new ViewModel(_context); _vm2 = new ViewModel(_context); _vm3 = new ViewModel(_context); _vm1.Callback += () => Debug.WriteLine("Callback of VM1: " + _vm1.LocalState); _vm2.Callback += () => Debug.WriteLine("Callback of VM2: " + _vm2.LocalState); _vm3.Callback += () => Debug.WriteLine("Callback of VM3: " + _vm3.LocalState); _vm1.Start(); _vm2.Start(); _vm3.Start(); } } public class ViewModel { private readonly TwitterContext _context; public event Action Callback; public int LocalState; public ViewModel(TwitterContext context) { _context = context; } public void Start() { var query = (from s in _context.Status where s.Type == StatusType.Public && s.Count == 10 select s); Debug.WriteLine("Hash code of ViewModel: " + query.GetHashCode()); query.AsyncCallback(statuses => { LocalState++; Debug.WriteLine("Hash code inside callback: " + GetHashCode()); Callback(); }).FirstOrDefault(); } } Now, if you run this, you will see that only one of the view models will get its state updated. Read on...
Building a Real-time Push App with Silverlight: Part 4
2011-09-05

Originally I wanted to avoid bringing in external libraries to keep the app as lean as possible, but then I realized that I would spend too much time reinventing the wheel. Twitter is deprecating basic authentication in the near future, which makes OAuth no longer optional. Rather than writing yet another Twitter client (if you’re curious I found a great reference here), I fired up NuGet and brought in LinqToTwitter, and while I’m there I brought in Autofac and Caliburn.Micro as well. Read on...
Building a Real-time Push App with Silverlight: Part 3
2011-08-28

In this part we’re going to fire up Expression Blend (the trial for version 5 can be found here) and do some UI work. In part 2, I created a simple Twitter client which connected to the streaming API, and connected to the sampling request which brings back random tweets. Here is the data template: <DataTemplate x:Key="TweetDataTemplate"> <Grid DataContext="{Binding}"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <TextBlock FontFamily="{StaticResource FontFamily}" FontSize="12" Text="{Binding Text}" TextWrapping="Wrap" /> <TextBlock Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontFamily="{StaticResource FontFamily}" FontSize="13.333" Foreground="BlueViolet" Text="{Binding ScreenName}" /> <TextBlock Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Bottom" FontFamily="{StaticResource FontFamily}" FontSize="9.333" Foreground="DarkCyan" Text="{Binding CreatedAt}" /> </Grid> </DataTemplate> This renders into something like this: The text is randomly generated from Blend’s sample capability, which is totally awesome as it allows designers to see what they’re working with, and keeps the sample data separate from the real data. Read on...