What is the right way to get SignalR working on Xamarin mobile apps?

HKWZHKWZ GBMember

I'm building Xamarin mobile applications and a SignalR Hub server.

I'm trying to incorporate SignalR sending and receiving in the Xamarin mobile apps.

Some people are saying use the signalr client nuget package

Other people are saying use the dev branch of the signalR library

Other people are saying use the portable class library that comes in the xamarin branch of the SignalR library (not found, can only see xamarin-package branch)

I'm confused, I don't know what is the right way to get the latest versions of SignalR to work on Xamarin mobile apps with SignalR Hub servers

Please advise

Posts

  • I haven't worked on this but I remember Greg Shackles posting a blog for an app he built using SignalR. He seems to have used the signalr client nuget package. You can download his sample and see if that works out for you.

    Note: The blog was posted in May 2013. So due to new changes, it may not work out. But until you do some Rnd yourself, you probably wont get an easy answer.

    http://www.gregshackles.com/2013/05/building-a-real-time-photo-gallery-with-xamarin-signalr-azure-and-webapi/

  • HKWZHKWZ GBMember
    edited December 2013

    Some people are saying use the signalr client nuget package

    worked best!

    just followed the tutorial on visualstudiomagazine and all worked like a charm.

  • moljacmoljac HRBeta ✭✭✭

    I'm developing sur[e]bet app server side and client (mobile and desktop) for friends of mine, currently in pre alpha, but first data was pushed through.

    Had problems on server side with VS 2010 (could not use netfx 4.5 and SignalR 2.x) mostly nuget package configuration and compatibility. Solved with SignalR sources 1.2.0 and project references. Currently seems OK. Server side is MVC4, WebAPI + SignalR.

    happy New Year!

    mel

  • MihaMarkicMihaMarkic SI ✭✭✭✭

    Sounds interesting as there is hard to get any server-stuff functionality on Android. Will you github the project or something?

  • moljacmoljac HRBeta ✭✭✭

    @MihaMarkic

    It is not server-stuff functionality it is server (MVC4 + WebAPI + SignalR) and mobile clients. SingalR demos are mostly javascript, but SignalR is much more than JS browser client.

    Greg's sample http://www.gregshackles.com/2012/07/using-signalr-in-monotouch-and-mono-for-android-apps/

    Mobile client is just sending messages to hub (let say for the sake of simplicity) on the server which sends it further to all connected clients in realtime (WebSockets with failover to some other stuff).

  • MihaMarkicMihaMarkic SI ✭✭✭✭

    Aaaa, ok, I misunderstood. Sadly there is no server functionality for Xamarin currently. AFAIK. I've had to build a Socket thing from scratch myself.

  • moljacmoljac HRBeta ✭✭✭

    no problems.

    Sockets? That is like dungeons of Moria. Why not http://androidapi.xamarin.com/?link=T%3aSystem.Net.HttpListener

    or owin? SignalR 2 is built on top of owin and not sure if self hosting (server side) capability is brought to mobile profiles.

    Regarding githubbing: not sure

  • mikeberlinmikeberlin USInsider, Beta, University, Developer Group Leader ✭✭
    edited January 2014

    I'm hoping to create a PCL project within Xamarin Studio that I reference from my iOS and Android projects all within the same solution. I can't seem to get it working.

    I either get the Core project building (the PCL project) and then throws an error at run time (see screenshot in this form http://forums.xamarin.com/discussion/comment/41756/#Comment_41756)

    or

    I get a compiler error from Xamarin studio (/Library/Frameworks/Mono.framework/Versions/3.2.6/lib/mono/4.0/Microsoft.CSharp.Targets: Error: Compiler crashed with code: 1)

    This is where my codebase is currently at. I attempted to build the SignalR Portal project from their github and then use it within my PCL project.

    I've posted my solution to github here:
    https://github.com/mikeberlin/Xamarin-SignalR-PCL-Clients

    The end goal is to update this article to use a PCL project and add Google Glass support:
    http://visualstudiomagazine.com/articles/2013/11/01/how-to-use-signalr-in-ios-and-android-apps.aspx

    Any help would be appreciated, especially since I'm just diving into PCL and SignalR.

    Thanks!

  • mikeberlinmikeberlin USInsider, Beta, University, Developer Group Leader ✭✭

    I took a closer look at the references used by @gshackles in the solution provided in the magazine article. He is using the 4.0 dll for the Newtonsoft.JSON project. So I tried changing to that reference in my PCL and everything is working lovely now. All projects are referencing the Core PCL project. w00t!

    Any idea why the 4.5 dll wouldn't work?

    As soon as I get a little further down the road with my Google Glass development I'm planning on expanding my repo to add Google Glass interaction with the chat room.

    I'm digging SignalR, very cool stuff!

  • gshacklesgshackles USInsider, University, Developer Group Leader ✭✭

    I mentioned that in the article:

    Second, the version of Json.NET picked by default does not work properly with Xamarin. Fortunately, the Nuget package also includes another version that works correctly, so replace that reference with the one found in Json.NET's "portable-net40+sl4+wp7+win8" folder

    It's due to a problem with Xamarin's reference assemblies that I believe is being addressed.

  • mikeberlinmikeberlin USInsider, Beta, University, Developer Group Leader ✭✭

    Gotcha, thanks for the info. I must have read right over that part in the article. That's what I get for reading late at night. :)

  • JeremyKolbJeremyKolb USMember ✭✭✭

    Have the xamarin issues been addressed since 1/30?

  • BRHBRH USMember ✭✭

    @JonDouglas‌ @gshackles‌ Any idea if these issues have been addressed yet? I'm trying to use the SignalR.Client NuGet package in a PCL and it doesn't seem to be connecting.

  • BRHBRH USMember ✭✭

    Fixed the issue; it seems everything is alright.

  • Hello, When I add the additional component in my project its giving error SignalR(Error) and the error is "The specified path, file name, or both are too long. The fully qualified name must be less than 260 and the directory name must be less than 248 characters".?

  • Plamen_IvanovPlamen_Ivanov USMember

    SignalR(Error) -> double click the component -> on SignalR page open 'Assemblies' tab -> if there are problems with the assemblies - remove them from 'References' and -> let the component to continue with the installation (see the red text with the error message)

  • Seem7teenSeem7teen USMember ✭✭
    edited February 2018

    @MuhammadBilalLiaquat > Hello, When I add the additional component in my project its giving error SignalR(Error) and the error is "The specified path, file name, or both are too long. The fully qualified name must be less than 260 and the directory name must be less than 248 characters".?

    Avoid having your project folder to be inside many folders.
    Always have your projects set up directly on a drive c:\ProjectHere or C:\MyProjectsFolder\ProjectHere

Sign In or Register to comment.