NVentimiglia / Realtime.Messaging.Xamarin

Realtime.co websockets in Xamarin
http://framework.realtime.co/
28 stars 9 forks source link

Reconsider Xamarin.Forms requirement? #4

Closed MattHarrington closed 8 years ago

MattHarrington commented 8 years ago

In a future version, would you consider dropping the Xamarin.Forms requirement? I'd like to use this in a traditional Xamarin.iOS project.

NVentimiglia commented 8 years ago

Working on that today

NVentimiglia commented 8 years ago

Update, I started work on a new unified websocket implementation which will remove the need to Xamarin Forms (We are using it for the dependency injection internally at the moment). I have a POC working, but, It needs some more testing before I`m willing to push it to master. Ill keep you updated.

MattHarrington commented 8 years ago

Outstanding. Thanks!

MattHarrington commented 8 years ago

I quickly skimmed the code, and it looks like you're only using it for push notifications. My project doesn't use push notifications, so if you had an early build to share I'd be interested.

NVentimiglia commented 8 years ago

That`s right. We are using the Message Center and the Dependency service for push notification. The Websocket dependency is easy via a factory, the others I need to think a bit about. I need a solid 6 hours to finish this up. Ill try to find some time this weekend.

NVentimiglia commented 8 years ago

Ok, I stripped out most of the dependencies for you. This new 'Lite' version is not on nuget, so you will need to pull directly from the repo.

https://github.com/NVentimiglia/Realtime.Messaging.Xamarin/tree/Lite

The one dependency is my websockets.pcl library. You will need to set it up correctly. Call Websockets.{platform}.WebsocketConnection.Link(); from your AppDelegate / Main Activity / ect.

https://github.com/NVentimiglia/Websockets.PCL

MattHarrington commented 8 years ago

Many thanks for this. I added Square.SocketRocket to Messaging.Sample.iOS, and it seems to work. The Android version also works. However, I can't connect via SSL with either sample. The non-Lite sample doesn't appear to have problems with SSL.

I haven't had time to investigate more. Perhaps it's a trivial fix. However, I wanted to report back here so you knew I had at least tried things out.

Also, in both versions I get this build warning:

Warning: All projects referencing Messaging.Sample.csproj must install nuget package Microsoft.Bcl.Build.

Adding that package to all relevant projects didn't seem to help. I haven't had a chance to investigate more.

NVentimiglia commented 8 years ago

Confirming the SSL issue for Android 4.4

Tried 3 other websocket implementations.

MattHarrington commented 8 years ago

I'm a little confused on setting up Websockets.PCL. The documentation for Xamarin.iOS says it requires Websockets.Ios and Square.SocketRocket. I might be missing something, but I see neither in the sample.

After upgrading Websockets.PCL in the sample to 1.1.0, AppDelegate.cs can no longer find things in the Websockets.Ios namespace.

Also, is Websockets.Ios in NuGet?

MattHarrington commented 8 years ago

Just to clarify, I have it working by including the source of your Websockets and Websockets.Ios projects. I'm confused about how to do this just with NuGet. I'm also confused about why the sample works with no apparent reference to Square.SocketRocket.

NVentimiglia commented 8 years ago

Yeah I noticed that also, I had to add the Websockets.Ios dll manually (from the nuget packages folder). I am not sure why it did not reference...

The package is targeting "MonoTouch+xamarinios10+xamarinios1". If you can tell me what I am doing wrong I will gladly post a fix.


<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
    <metadata>
        <id>Websockets.Pcl</id>
        <version>1.1.0</version>
        <title>Xamarin Portable Websockets</title>
        <authors>Nicholas Ventimiglia</authors>
        <owners>Nicholas Ventimiglia</owners>
        <projectUrl>https://github.com/NVentimiglia/Websockets.PCL</projectUrl>
        <iconUrl>https://avatars3.githubusercontent.com/u/125889?v=3&amp;s=460</iconUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <developmentDependency>true</developmentDependency>
        <description>C# Websockets for all platforms using native bridges.</description>
        <summary>C# Websockets for all platforms using native bridges.</summary>
        <releaseNotes>Added 'GetAllConnections' to factory for better Application Termination support.</releaseNotes>
        <copyright>Nicholas Ventimiglia</copyright>
        <language>en-001</language>
        <tags>Xamarin, Pcl, Websockets, Android, Ios</tags>
        <dependencies>
            <group targetFramework="WindowsPhone8.0">
                <dependency id="WebSocket4Net" version="0.14.1" />
            </group>
            <group targetFramework="MonoTouch0.0">
                <dependency id="Square.SocketRocket" version="0.4.2.0" />
            </group>
        </dependencies>
    </metadata>
    <files>
        <file src="..\Websockets.Droid\bin\Release\Websockets.Droid.dll" target="lib\MonoAndroid\Websockets.Droid.dll" />
        <file src="..\Websockets.Droid\bin\Release\WebSockets.PCL.dll" target="lib\MonoAndroid\WebSockets.PCL.dll" />
        <file src="..\Websockets.Ios\bin\iPhone\Release\Websockets.Ios.dll" target="lib\MonoTouch+xamarinios10+xamarinios1\Websockets.Ios.dll" />
        <file src="..\Websockets.Ios\bin\iPhone\Release\WebSockets.PCL.dll" target="lib\MonoTouch+xamarinios10+xamarinios1\WebSockets.PCL.dll" />
        <file src="..\Websockets.Net\bin\Release\Websockets.Net.dll" target="lib\net45\Websockets.Net.dll" />
        <file src="..\Websockets.Net\bin\Release\WebSockets.PCL.dll" target="lib\net45\WebSockets.PCL.dll" />
        <file src="..\Websockets.Net\bin\Release\WebSockets.PCL.dll" target="lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\WebSockets.PCL.dll" />
        <file src="..\Websockets.Universal\bin\Release\WebSockets.PCL.dll" target="lib\uap10.0\WebSockets.PCL.dll" />
        <file src="..\Websockets.Universal\bin\Release\Websockets.Universal.dll" target="lib\uap10.0\Websockets.Universal.dll" />
        <file src="..\Websockets.WP8\Bin\Release\WebSockets.PCL.dll" target="lib\wp8\WebSockets.PCL.dll" />
        <file src="..\Websockets.WP8\Bin\Release\Websockets.WP8.dll" target="lib\wp8\Websockets.WP8.dll" />
    </files>
</package>
NVentimiglia commented 8 years ago

https://github.com/NuGet/NuGetGallery/issues/2885

azchohfi commented 8 years ago

Hello everybody. Is the NuGet package for the Lite version being hold because of this NuGet issue?

NVentimiglia commented 8 years ago

@azchohfi

Try this https://www.nuget.org/packages/RealtimeFramework.Messaging.Portable/

azchohfi commented 8 years ago

Thanks! I will!

azchohfi commented 8 years ago

Worked like a charm, by the way.

azchohfi commented 8 years ago

I'm not sure if this stopped working or what, but if I use the RealtimeFramework.Messaging.Portable NuGet it does not work. I have to build from source. If fails on connect, asynchronously calling OnException (ex = {Realtime.Messaging.Exceptions.OrtcNotConnectedException: Unable to connect}).