SignalR for Unity3D to Universal App communication Part 1

Recently, I have been working on my bachelor’s thesis. The project required my Universal Windows library to communicate with my Unity3D project; direct communication was not an option due to .Net version Unity is using and its incompatibility with Band SDK.

I did some research and stumbled upon SignalR. Basically, SignalR is two-way, client-server communication framework, it implements the connection boilerplate for you and uses fall-back protocols to ensure backward compatibility.

SignalR is open source and already has many established libraries to use in many languages such as:

  • Natively on .NET framework 3.5+
  • Apple platform: the Objective-C library is well maintained and quite active on reported bugs. There’s a new library for swift (SwiftR), but I haven’t personally used it.
  • For using within Android, you can use Java-Client. (works for any Java program)
  • And finally, there’s this awesome guy who saved me with SignalR client for .NET 2.0

At first glance, SignalR .NET2.0 specified it uses protocol 1.+, whereas universal windows uses SignalR2.0; The official website did not mention if they were compatible or not, thankfully they were compatible.

SignalR Usage

SignalR is quite easy to get started, you add the reference to your project and after typical linking procedure, you’re ready to get down to it.

On SignalR server, you’ll need to set the behaviour of sending messages as well as receiving from client. For my simple requirement, I found broadcasting the message to be the way to go; I had two clients and each listened to a different message, so I did not work on identifying listeners.

The usefulness of SignalR was the minimal latency between communication [tested on the same machine].

I’ll discuss implementation details on Part 2.

 

ASP.NET Core Nuclear option

ASP.NET Core Nuclear option

Few hours ago, Microsoft announced

ASP.NET 5 is dead – Introducing ASP.NET Core 1.0 and .NET Core 1.0

And correlating changes are already in motion on the Github repo.

Some components are not yet ready e.g. SignalR, but most supported frameworks and tools correlated with ASP.NET has been reset to 1.0:

  • ASP.NET 5 is now ASP.NET Core 1.0.
  • .NET Core 5 is now .NET Core 1.0.
  • Entity Framework 7 is now Entity Framework Core 1.0 or EF Core 1.0 colloquially.
  • NuGet packages name changing accordingly e.g. aspnet.mvc into aspnetcore.mvc.

The cool part about ASP.NET Core is that it is cross platform and can run also on Desktop CLR.

ASP.NET Core is currently RC1, RC2 will follow in February and the RTM version will become available in March.

You can read the original post on Scott Hanselman’s blog post: http://www.hanselman.com/blog/ASPNET5IsDeadIntroducingASPNETCore10AndNETCore10.aspx

Code Generation using T4 Text Templates

I worked recently with ASP.NET , the project I was involved in required me to develop WCF service library to handle the access to the database and do defined validation and transformations.

After developing few classes I started to notice how repetitive the process is:

  • Declare the Insert/Update/Get/List and Delete methods signatures.
  • Create classes that will hold the returned items from the Database.
  • Implement the said methods in the library class.

After a bit of searching to avoid the boilerplate code, I stumbled upon T4; It is initially a text file where you input the template you want your generated code to follow, then voila, you have the code generated for you.

The catch

Using T4 templates before the requirements are fully clear can result in wasted time; I felt T4 is most efficient when implemented in a project following Waterfall development methodology. When you’re working within an Agile development, this becomes more controversial to use as the time you need to set up a new template might be very close in time to create the results yourself.

Nevertheless..

T4 is SO RAD. I turned in an assignment I had a week to finish the next day.. including learning about T4 for the first time!

I just had to specify in the skeleton of my classes once, then loop over them with the class names I desire. Another important advantage I noticed was that it indirectly enforced a naming schema; I had the template class PascalCased and properly named, and then ended up with all my classes properly named and formatted.

It was really nice when I had to modify one line of code across multiple classes, I would just generate them from the template after I modify it.

 

Finally, I would be careful when to use code generation.  I am so happy I learned about it and got to use it in a real project. You can also learn how to use it on MSDN or here in this video.

Hello Worlds;

Hello Worlds;

A lot of excitement, rants and experiences wanted to make it to my first blog post, but a current goal with strong momentum seemed more fitting.

I have always confronted my mesmerisation of different cultures; Interactions of people from various backgrounds offered me great insights to life, but I was still being kept in the dark in wonder about “what’s actually different”.

In my opinion, cultural differences lie in the small weird humor, in words you say on typical everyday life events, and in the look and care you handle a lover with. Books have always aided me in my wonders, though I was never quite the bookworm who “lives the book” he/she read. nevertheless, I once again I turn to books to explore what the world written culture has to share.

Thus I have decided on my new “casual” goal; to read a book from each country in the world. That means 196 books are going from my shelf to my head, this will be too much details to keep in my brain -especially when my brain is busy with my graduation project- that’s why I write to you ,future me, to keep a bird-eye-view on your findings.

I have started with the first book; it’s Sea of Poppies by Amitav Ghosh, an Indian author, it is a historical fiction discussing the Opium industry and Slavery in India under Great Britain’s empire. Truly captivating read, but will discuss it upon finishing it.