Giter Site home page Giter Site logo

Comments (9)

AlejandroHuerta avatar AlejandroHuerta commented on September 27, 2024 1

@Mazyod I'll be looking into getting this working on Unity soon but from that error I believe the Newtonsoft library will have trouble running in Unity unless you select the .net 2.0 fullset. I may fork the project and use Unity's JsonUtility that was released in 5.2(I believe).

from csharpphoenixclient.

AlejandroHuerta avatar AlejandroHuerta commented on September 27, 2024

@JulianMayorga Is it websocketsharp that makes this incompatible with Unity3d?

from csharpphoenixclient.

Mazyod avatar Mazyod commented on September 27, 2024

I would very much like to cast my vote on this one, as well as hope to eventually get to it.

from csharpphoenixclient.

Mazyod avatar Mazyod commented on September 27, 2024

Actually, I somehow got WebsocketSharp to compile under Mono 2.0, but this library fails to compile.

Build FAILED.
Errors:

/*/CSharpPhoenixClient-master/PhoenixClient.csproj (Build) ->
/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->

    Channel.cs(116,13): error CS1502: The best overloaded method match for `PhoenixChannels.Channel.On(string, System.Action<Newtonsoft.Json.Linq.JObject,string>)' has some invalid arguments
    Channel.cs(116,37): error CS1503: Argument `#2' cannot convert `System.Action<object,string>' expression to type `System.Action<Newtonsoft.Json.Linq.JObject,string>'
    Channel.cs(121,13): error CS1502: The best overloaded method match for `PhoenixChannels.Channel.On(string, System.Action<Newtonsoft.Json.Linq.JObject,string>)' has some invalid arguments

---------------------- Done ----------------------

Update

Seems Microsoft.CSharp is the culprit, I can't find a compatible package for Mono 3.5

from csharpphoenixclient.

Mazyod avatar Mazyod commented on September 27, 2024

@AlejandroHuerta Thanks for the heads up.. I am getting desperate to get this working, so I am working extra hours this weekend to get it done. Here is what I tried:

  • JsonUtility isn't a good alternative, since it doesn't have a generic JSON object to replace JObject
  • I found SimpleJSON, which has JSONNode, JSONClass, and so on .. I am integrating that now.

If you are willing to collaborate on this, let me know. My email is on my profile.

from csharpphoenixclient.

AlejandroHuerta avatar AlejandroHuerta commented on September 27, 2024

@Mazyod I have experience using Netwonsoft.Json. There's no need to rewrite using those libraries, simply replacing the newtsonsoft.json.dll with the .net 2.0 version will allow Unity to use it. But this does require the full .net 2.0 api setting like I mentioned. A few other issues lay in Channel.cs where on line #114 and # 119 Action must change to Action. In Socket.cs you need to do something similar with OnClose (ln #102) and OnError (ln #108).

I also noticed that Unity dislikes the built dll of PhoenixClient so simply copying over the class files to a Unity folder will solve this. Then it's just a matter of placing the websocket-sharp and newtonsoft-json dlls in the Plugins folder(you may have to create this folder).

With that I was able to hit the sample phoenix project but haven't gotten past that as I wont have time until the Monday. Hope this helps you get started!

from csharpphoenixclient.

Mazyod avatar Mazyod commented on September 27, 2024

Thanks for sharing your findings again, @AlejandroHuerta, but I am still facing lots of issues:

First, I couldn't find a Newtonsoft.JSON version compatible with Mono 2.0. It would be great to share a link to that.

Second, I finally got the websocket stuff out of the way by using websocket-sharp provided by unity people themselves here.

Finally, I am now facing issues with the $"string {variable}" syntax, since you suggested dropping the source code into the Unity project, rather than building a managed plugin.

Will hopefully be back with a working build in a few hours... 👋


Update

As a quick update, after I've dealt with the $ string formatters, there were small issues with function declarations using => and properties that only had { get; } without a set. Once all that was resolved, the project finally compiled. Time to do a test run.

from csharpphoenixclient.

Mazyod avatar Mazyod commented on September 27, 2024

Oh ... I just realized I was using https://github.com/jfis/dn-phoenix, not this library 🌴 Sorry for disturbing you all. I also found a Mono 2.0 Newtonsoft.JSON, thanks.

from csharpphoenixclient.

mjaric avatar mjaric commented on September 27, 2024

This library should work now with unity3d and any .net supported platform. it is now in nuget.org It is BETA! so please give it a try and report any bugs.

By my opinion this "callback style", as original author built it, is not pretty. But I'm not going to argue since it is more cosmetic thing. But if my opinion counts, api should be async/await style. Let me know what do you think! If you find this callback style annoying I could change and add queues so pushes can be scheduled before connection is established or channel is joined. Queue max lang could be controlled is we expose connection options so we keep queue slim so mobile apps have option to be easy on device resources.

from csharpphoenixclient.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.