Announcement

Collapse
No announcement yet.

[Plugin] Socket.io Client

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    Update to 0.2.5
    -Change event names and signatures
    -Add wider support for raw message emitting and receiving

    Apart from adding the missing raw methods for C++ for callbacks and raw message types, I've added a little bit more about how to use the plugin in C++. I expect this to get a bit simpler as I get auto-json conversion working at some point. Grab the latest source at the repo https://github.com/getnamo/socketio-client-ue4
    Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

    Comment


      #32
      Update to 0.4.0
      -Added SIOJson for Blueprint Json construction and conversion, based on VaRest
      -Auto-conversion for nodes
      -Blueprint callbacks and events bound to functions references by function name
      -Conversion of JsonObjects to and from UStructs, including Blueprint UStructs with automatically trimmed long names into readable short names
      -Overloaded EmitNative for all expect UE native data types
      -Much simplified C++ usage based on FJsonValue and FJsonObject including nested binary support (hackery!)
      -and much more

      Grab it at the usual: https://github.com/getnamo/socketio-client-ue4/releases

      Seeing as I will probably use this plugin in production, decided to fix all major workflow issues with the plugin, it's accumulated so many changes for this update, it jumped two major versions internally! Check out the github readme for the latest examples and documentation!

      Some samples of the changes:

      Blueprint construction, thanks in large parts to SIOJson forked from ufna's VaRest


      Any unreal struct you make, including blueprint ones are supported for easy conversion to json!



      Binary and decode your complex nested data structures straight in blueprint


      Good workflow from auto-conversion for native types


      Callbacks, binding events to functions in your blueprints and encode/decode json straight from blueprints!




      Much improved C++ workflow based on native FJsonValue and FJsonObject. Support for nested raw binary data within these structures!

      Code:
      TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject);                        //make object option2
      JsonObject->SetBoolField(FString("myBool"), false);
      JsonObject->SetStringField(FString("myString"), FString("Socket.io is easy"));
      JsonObject->SetNumberField(FString("myNumber"), 9001);
      
      JsonObject->SetField(FString("myBinary1"), USIOJConvert::ToJsonValue(Buffer));              //binary option1 - shorthand
      JsonObject->SetField(FString("myBinary2"), MakeShareable(new FJsonValueBinary(Buffer)));    //binary option2
      
      JsonObject->SetArrayField(FString("myArray"), ArrayValue);
      JsonObject->SetObjectField(FString("myNestedObject"), SmallObject);
      
      SIOClientComponent->EmitNative(FString("nativeTest"), JsonObject);
      Any UStruct to Json and easy c++ callbacks

      Code:
      //Set your struct variables
      FTestCppStruct TestStruct;
      TestStruct.Name = FString("George");
      TestStruct.Index = 5;
      TestStruct.SomeNumber = 5.123f;
      
      SIOClientComponent->EmitNative(FString("callbackTest"),  FTestCppStruct::StaticStruct(), &TestStruct, [&](auto Response)
      {
          auto Message = Response[0]->AsObject();
      
          //Show what we received
          UE_LOG(LogTemp, Log, TEXT("Received a response: %s"), *USIOJConvert::ToJsonString(Message));
      
          //Set our second struct to the new values
          USIOJConvert::JsonObjectToUStruct(Message, FTestCppStruct::StaticStruct(), &MemberStruct);
      
          //Show that struct
          UE_LOG(LogTemp, Log, TEXT("Our received member name is now: %s"), *MemberStruct.Name);
      });
      Last edited by getnamo; 11-17-2016, 02:30 AM.
      Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

      Comment


        #33
        Originally posted by bot2600 View Post
        First, awesome work! And they are really clean to use from Blueprints. I do have one quick question though. I have a node server that I have been using as the backend for Unity and am looking to test it out against UE4, which there wasn't a client for socket.io when I first looked, so this is awesome!

        The issue I am running into is if I pass a JSON object instead of a string, I dont seem to get anything back from the plugin. Are there plans to support more advanced objects?

        Thanks!

        Edit: Adding screenshot, unless I call JSON.stringify on my objects this always goes to empty string

        [ATTACH=CONFIG]101465[/ATTACH]
        Just wanted to ping you, if you still want to use this plugin give the latest version a try, it can now handle all Json types straight in blueprints
        Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

        Comment


          #34
          Hi Getnamo,

          I saw you and we chatted at UE4London last week (i'm the gameshow guy) - thanks for another amazing demo! Afterwards we were talking about socket.io and all the cool stuff you've been doing with it so I thought i'd have a go at implementing it in my project (The gameshow).

          I'm quite interested in the auto-populating-struct from JSON functions, and i've had it working on a few tests. Is it possible to populate a struct containing an array of another type of struct? In my case i've got a QUESTION object (array of) which contains strings and some ints, but it also contains another array containing up to 4 ANSWER structs.

          I've tried to cobble this together (I'm populating it from outside, rather than converting the struct and sending it out of the engine) but I get an engine crash when I send in the data.

          Because of a weird issue I couldn't actually get my node server to communicate with the socket.io plugin you made - i'm just using the conversion nodes to convert stringified JSON to the struct - I don't know if that makes a difference.

          Dan.

          Comment


            #35
            Originally posted by Dannington View Post
            Hi Getnamo,

            I saw you and we chatted at UE4London last week (i'm the gameshow guy) - thanks for another amazing demo! Afterwards we were talking about socket.io and all the cool stuff you've been doing with it so I thought i'd have a go at implementing it in my project (The gameshow).

            I'm quite interested in the auto-populating-struct from JSON functions, and i've had it working on a few tests. Is it possible to populate a struct containing an array of another type of struct? In my case i've got a QUESTION object (array of) which contains strings and some ints, but it also contains another array containing up to 4 ANSWER structs.

            I've tried to cobble this together (I'm populating it from outside, rather than converting the struct and sending it out of the engine) but I get an engine crash when I send in the data.

            Because of a weird issue I couldn't actually get my node server to communicate with the socket.io plugin you made - i'm just using the conversion nodes to convert stringified JSON to the struct - I don't know if that makes a difference.

            Dan.
            Great to hear from you Dan!

            The key with JSON <-> struct conversion is that the keys have to match for the structure to fill properly.

            In both C++ and BP structs, UE4 follows PascalCase whereas JSON generally expects camelCase. UE4 json conversion automatically converts struct properties into camelCase, so this is the format your data should hold.

            E.g.:


            the vector struct will convert into
            Code:
            {
              "x": 1,
              "y": -22.3,
              "z": 9001.5
            }
            (note the lower case properties)

            So the first thing to check is to make sure all your json values use camelCase.

            Regarding struct of structs, in the tensorflow-ue4-mnist-example (final demo) I used a similar structure, I had a BP struct called DrawingStruct, which contained an array of StrokeStruct, these are then populated via json->struct conversion when the webclient sends strokes. So that method should work.

            Note that the json format for that example is something like:

            Code:
            {  
               "strokes":[  
                  {  
                     "stroke":[  
                        {  
                           "x":3.9862472895741048,
                           "y":4.7506390606304745
                        },
                        {  
                           "x":4.0216255688082621,
                           "y":4.7864079379896598
                        }
                     ]
                  },
                  {  
                     "stroke":[  
                        {  
                           "x":20.610493174572404,
                           "y":4.2582182499755357
                        },
                        {  
                           "x":20.570929353931788,
                           "y":4.2949240704982428
                        }
                     ]
                  }
               ]
            }
            This was essentially a workaround for an array of arrays in BPs.

            Regarding node.js communication, make sure you're using socket.io version 1.0.

            If those tips don't solve it, PM me your logs that you get from the crash and if you can post any BP graphs showing how it's linked up, maybe we can figure out what's the issue
            Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

            Comment


              #36
              Excited about your recent post [MENTION=548]getnamo[/MENTION] #tensorflowUE4, just saw it today - thanks !!
              https://github.com/getnamo/tensorflow-ue4-mnist-example


              Originally posted by getnamo View Post
              Great to hear from you Dan!

              The key with JSON <-> struct conversion is that the keys have to match for the structure to fill properly.

              In both C++ and BP structs, UE4 follows PascalCase whereas JSON generally expects camelCase. UE4 json conversion automatically converts struct properties into camelCase, so this is the format your data should hold.

              E.g.:


              the vector struct will convert into
              Code:
              {
                "x": 1,
                "y": -22.3,
                "z": 9001.5
              }
              (note the lower case properties)

              So the first thing to check is to make sure all your json values use camelCase.

              Regarding struct of structs, in the tensorflow-ue4-mnist-example (final demo) I used a similar structure, I had a BP struct called DrawingStruct, which contained an array of StrokeStruct, these are then populated via json->struct conversion when the webclient sends strokes. So that method should work.

              Note that the json format for that example is something like:

              Code:
              {  
                 "strokes":[  
                    {  
                       "stroke":[  
                          {  
                             "x":3.9862472895741048,
                             "y":4.7506390606304745
                          },
                          {  
                             "x":4.0216255688082621,
                             "y":4.7864079379896598
                          }
                       ]
                    },
                    {  
                       "stroke":[  
                          {  
                             "x":20.610493174572404,
                             "y":4.2582182499755357
                          },
                          {  
                             "x":20.570929353931788,
                             "y":4.2949240704982428
                          }
                       ]
                    }
                 ]
              }
              This was essentially a workaround for an array of arrays in BPs.

              Regarding node.js communication, make sure you're using socket.io version 1.0.

              If those tips don't solve it, PM me your logs that you get from the crash and if you can post any BP graphs showing how it's linked up, maybe we can figure out what's the issue

              Comment


                #37
                Originally posted by dr.purple View Post
                Excited about your recent post [MENTION=548]getnamo[/MENTION] #tensorflowUE4, just saw it today - thanks !!
                https://github.com/getnamo/tensorflow-ue4-mnist-example
                It needs a bit of work before it is drag and drop ready. Atm you need to install pip and tensorflow separately, but I'm making progress on encapsulating pip dependencies and python scripts into plugins themselves. That should in theory also allow other future python -> bp plugins to be built with drag and drop installation. Stay tuned
                Last edited by getnamo; 01-17-2017, 06:33 PM.
                Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

                Comment


                  #38
                  Hi [MENTION=548]getnamo[/MENTION] - thanks for the tip on socket.io v1 - I expect it's that.

                  I realised (I'm a java newbie) that on my node server and in the SQLite database I'm using, I was stringifying the answer's struct - so my json contained the normal strings and ints, but the answers were just an array of strings rather than valid json- it's been a whirlwind of learning this last 2 weeks!

                  Cheers again though - I can see socket.io playing a huge part in my future projects. I might make a video tutorial like I did for Monsieur gustav's ue4osc plugin if I get a spare moment - what do you think? I was really interested when you first did your presentation on this but had absolutely no idea about how to set up a node server - I could do a really simple introduction to both, making a web interface into the engine.

                  Comment


                    #39
                    Originally posted by Dannington View Post
                    Hi [MENTION=548]getnamo[/MENTION] - thanks for the tip on socket.io v1 - I expect it's that.

                    I realised (I'm a java newbie) that on my node server and in the SQLite database I'm using, I was stringifying the answer's struct - so my json contained the normal strings and ints, but the answers were just an array of strings rather than valid json- it's been a whirlwind of learning this last 2 weeks!

                    Cheers again though - I can see socket.io playing a huge part in my future projects. I might make a video tutorial like I did for Monsieur gustav's ue4osc plugin if I get a spare moment - what do you think? I was really interested when you first did your presentation on this but had absolutely no idea about how to set up a node server - I could do a really simple introduction to both, making a web interface into the engine.
                    Awesome to see good progress, learning something new is always challenging but worth it when it all clicks together. A video tutorial would be a great addition, looking forward to seeing what you come up with !
                    Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

                    Comment


                      #40
                      Hi [MENTION=548]getnamo[/MENTION], nice work btw.

                      My UE4Editor is crashing as soon as I am connecting to my server. I should say that I am not using an socket.io server. With javascript in a browser everything works fine (communication with a sps-controller). I am using version 4.14.3 of unreal.
                      Do you have any ideas? I can't even debug because the whole Unreal crashes, only with a short info "not working any more..." It crashes both on blueprint and on c++. Tried also the latest release(0.4.1) and my own compilation with the latest source files from github (0.4.7).

                      Thanks,
                      Steffen

                      Comment


                        #41
                        Hi @Getnamo

                        Little update on my problem with UESocket.io not connecting to my server. I'm not really sure how I've got it set up as i'm basically fudging my server code together, but it seems that the way I was hosting my webpage may have something to do with it. I started getting connections to UE4 when I set up second socket.io 'instance' in my server code, listening on another port.

                        My original setup is a node server which acts as a CMS reading and writing to an SQLite database and serving up a webpage. I bolted on lots of other stuff like OSC and stuff - and originally I was running with XMLHTTPrequests rather than Socket.io - then I switched to socket.io for communication between the server and the served webpage-interface but when I tried to connect from UE4 through the same address and port I got nothing.

                        Don't know what I did, and I don't' really like running 2 ports (it seems clunky) but it's working now.

                        Comment


                          #42
                          Originally posted by Dannington View Post
                          Hi @Getnamo

                          Little update on my problem with UESocket.io not connecting to my server. I'm not really sure how I've got it set up as i'm basically fudging my server code together, but it seems that the way I was hosting my webpage may have something to do with it. I started getting connections to UE4 when I set up second socket.io 'instance' in my server code, listening on another port.

                          My original setup is a node server which acts as a CMS reading and writing to an SQLite database and serving up a webpage. I bolted on lots of other stuff like OSC and stuff - and originally I was running with XMLHTTPrequests rather than Socket.io - then I switched to socket.io for communication between the server and the served webpage-interface but when I tried to connect from UE4 through the same address and port I got nothing.

                          Don't know what I did, and I don't' really like running 2 ports (it seems clunky) but it's working now.
                          It could be that your other service is holding the other port and you can't connect to it with another service. See http://stackoverflow.com/questions/3...80-on-a-server, specifically:

                          Ports are a way to multiplex IP addresses so that different applications can listen on the same IP address/protocol pair. Unless an application defines its own higher-level protocol, there is no way to multiplex a port. If two connections using the same protocol have identical source and destination IPs and identical source and destination ports, they must be the same connection.

                          There are ways to forward ports however so that e.g. port 80 requests will happen on 3000 transparently to the user, which should work for socket.io traffic as well.


                          Originally posted by SteffenN View Post
                          Hi [MENTION=548]getnamo[/MENTION], nice work btw.

                          My UE4Editor is crashing as soon as I am connecting to my server. I should say that I am not using an socket.io server. With javascript in a browser everything works fine (communication with a sps-controller). I am using version 4.14.3 of unreal.
                          Do you have any ideas? I can't even debug because the whole Unreal crashes, only with a short info "not working any more..." It crashes both on blueprint and on c++. Tried also the latest release(0.4.1) and my own compilation with the latest source files from github (0.4.7).

                          Thanks,
                          Steffen
                          If this is related to the socket.io-client plugin, PM me your logs under saved related to the crash. They usually have more information. Also have you tried a clean project? What platform are you using this on?
                          Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

                          Comment


                            #43
                            I'm having a similar crash as SteffanN, but only in packaged builds. I've experienced crashes in non-packaged builds if I fail to connect. I have tried in a blank project with variable success. The frustrating thing is that is seems really inconsistent. Sometimes ti connects, sometimes it crashes. Mostly crashing these days.
                            https://1drv.ms/v/s!AuBS3k7nbgsXjQkGIexhhJx_dJxK
                            Here's an actor crashing after 5 seconds.
                            It does seem more stable if I connect with the PC using auto-connect or in the construction script. But that's not a guarantee. The logs are pretty unhelpful as they simply end before the crash.

                            Comment


                              #44
                              Originally posted by Tom Shannon View Post
                              I'm having a similar crash as SteffanN, but only in packaged builds. I've experienced crashes in non-packaged builds if I fail to connect. I have tried in a blank project with variable success. The frustrating thing is that is seems really inconsistent. Sometimes ti connects, sometimes it crashes. Mostly crashing these days.
                              https://1drv.ms/v/s!AuBS3k7nbgsXjQkGIexhhJx_dJxK
                              Here's an actor crashing after 5 seconds.
                              It does seem more stable if I connect with the PC using auto-connect or in the construction script. But that's not a guarantee. The logs are pretty unhelpful as they simply end before the crash.
                              Got an example minimal project to replicate the crash?

                              I've been able to replicate hangs from not using auto-connect, but haven't found a way to crash due to socket.io. What's the server you're connecting to? does it have socket.io v1.4 or newer?
                              Plugins: Node.js - TensorFlow - Socket.io Client - ZipUtility - Leap Motion - Hydra - Myo - RealSense

                              Comment


                                #45
                                Great Plugin.

                                Just upgraded to UE 4.15(Github Version) but the Plugin no longer works, the editor tries to compile when i start my project but it fails.

                                \Plugins\socketio-client-ue4\Source\SIOJEditorPlugin\Private\SIOJ_BreakJson.cpp(34): error C2653: 'FEdGraphUtilities': is not a class or namespace name
                                \Plugins\socketio-client-ue4\Source\SIOJEditorPlugin\Private\SIOJ_BreakJson.cpp(34): error C3861: 'GetNetFromPin': identifier not found
                                \Plugins\socketio-client-ue4\Source\SIOJEditorPlugin\Private\SIOJ_BreakJson.cpp(121): error C2653: 'FEdGraphUtilities': is not a class or namespace name
                                \Plugins\socketio-client-ue4\Source\SIOJEditorPlugin\Private\SIOJ_BreakJson.cpp(121): error C3861: 'GetNetFromPin': identifier not found
                                thats the error in the log

                                edit:

                                fixed it by adding
                                #include "EdGraphUtilities.h

                                in the "SIOJ_BreakJson.cpp" file
                                Last edited by KenshiHH; 02-16-2017, 04:54 PM.

                                Comment

                                Working...
                                X