SignalR and Vidyano
After the announcement of David Fowler about the new release of SignalR, I had to try it out on my Learning Japanese web app (latest commit). I’ve started with basic chat app and added some Vidyano related calls to it (it will automatically translate between English <-> Japanese).
So first I had to add the correct NuGet package to the Web site, instead of the App_Start code I’ve changed the Vidyano code to map the WebAPI routes in the Global.asax.cs because I already had the file.
With SignalR they have added a MapHubs extension method, in Vidyano we can use the WebControllerFactory’s RegisterRoutes to do the same. SignalR comes first because it’ll handle the /signalr paths, and Vidyano handles the rest.
My hub is mostly the basic chat hub which can be found in the Chat.cs file:
My JapaneseKanaClassifier class is used to see if the message contains any Japanese characters (Kanji, Hiragana or Katakana) and if so it will be translated to English, otherwise it will assume that it is in English and it will be translated to Japanese.
As for the client, I’ve used a virtual persistent object Chat to view it in my application and the Chat template is using the following:
Again nothing special, when clicking on the Say button, or pressing Return it will send the message and the current friendlyUserName to the service.
You can check it all out on http://vidyano.apphb.com/#!/Chat