topfreegames / libpitaya-cluster

This repo contains a c++ lib with pitaya's cluster logic for creating backend pitaya servers in other programming languages
MIT License
21 stars 8 forks source link

how to use the unity demo #1

Open ghost opened 5 years ago

ghost commented 5 years ago

please tell me how to use the unity demo,thank you!

ghost commented 5 years ago

when i click the sendrpc button, report the bug follows:

NotSupportedException: Specified method is not supported.
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.ClassLibraryReference (System.String name, SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnityProject project) (at <ccdfbc74879a406f84370443f1ee15bd>:0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateProject (SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit unit) (at <ccdfbc74879a406f84370443f1ee15bd>:0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateSolution () (at <ccdfbc74879a406f84370443f1ee15bd>:0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateSolutionFromAssetDatabase () (at <ccdfbc74879a406f84370443f1ee15bd>:0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProject () (at <ccdfbc74879a406f84370443f1ee15bd>:0)
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnPreGeneratingCSProjectFiles () (at <ccdfbc74879a406f84370443f1ee15bd>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
UnityEditor.AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles () (at /Users/builduser/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:205)
UnityEditor.VisualStudioIntegration.SolutionSynchronizer.Sync () (at /Users/builduser/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:210)
UnityEditor.SyncVS.SyncIfFirstFileOpenSinceDomainLoad () (at /Users/builduser/buildslave/unity/build/Editor/Mono/SyncProject.cs:197)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
felipejfc commented 5 years ago

Hi @jmesyan, could you specify better how you're trying to test it? Like, against which server? Are you running all pitaya deps? (nats, etcd)?

I've updated master branch for using the c++ plugin and also updated the unity-example, can you try it again?

best

ghost commented 5 years ago

@felipejfc I use the macbook,and the environment next:

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/admin/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/code"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.4/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rs/g895d51j2qjbkq2l0zxm7bym0000gn/T/go-build341709355=/tmp/go-build -gno-record-gcc-switches -fno-common"

now when I make build, follow the error:

make build
can't load package: package github.com/topfreegames/libpitaya-cluster: no Go files in /code/src/github.com/topfreegames/libpitaya-cluster
make: *** [build] Error 1
felipejfc commented 5 years ago

hi @jmesyan that's because we have switched from a golang implementation of the native plugin to a c++ one, the reason is that unity has some troubles dealing with go native plugins

ghost commented 5 years ago

@felipejfc , make error:

sudo make build-mac-unity
Password:
Makefile:36: warning: overriding commands for target `build-mac'
Makefile:24: warning: ignoring old commands for target `build-mac'
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=10.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

conanfile.txt: Installing package
Requirements
    OpenSSL/1.0.2o@conan/stable from 'conan-center' - Cache
    zlib/1.2.11@conan/stable from 'conan-center' - Cache
Packages
    OpenSSL/1.0.2o@conan/stable:75c89fa3e1091e5c3911f9847d6d4abd7c60e60f - Cache
    zlib/1.2.11@conan/stable:534dcc368c999e07e81f146b3466b8f656ef1f55 - Cache

zlib/1.2.11@conan/stable: Already installed!
OpenSSL/1.0.2o@conan/stable: Already installed!
conanfile.txt: Generator cmake created conanbuildinfo.cmake
conanfile.txt: Generator cmake_paths created conan_paths.cmake
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
-- The C compiler identification is AppleClang 10.0.0.10001145
-- The CXX compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Current conanbuildinfo.cmake directory: /code/src/github.com/topfreegames/libpitaya-cluster/cpp-lib/_builds/mac-unity
-- Conan: Using cmake targets configuration
-- Library ssl found /Users/admin/.conan/data/OpenSSL/1.0.2o/conan/stable/package/75c89fa3e1091e5c3911f9847d6d4abd7c60e60f/lib/libssl.a
-- Library crypto found /Users/admin/.conan/data/OpenSSL/1.0.2o/conan/stable/package/75c89fa3e1091e5c3911f9847d6d4abd7c60e60f/lib/libcrypto.a
-- Library z found /Users/admin/.conan/data/zlib/1.2.11/conan/stable/package/534dcc368c999e07e81f146b3466b8f656ef1f55/lib/libz.a
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Boost version: 1.68.0
CMake Error at CMakeLists.txt:43 (add_subdirectory):
  The source directory

    /code/src/github.com/topfreegames/libpitaya-cluster/cpp-lib/deps/grpc

  does not contain a CMakeLists.txt file.

CMake Error at CMakeLists.txt:45 (add_subdirectory):
  The source directory

    /code/src/github.com/topfreegames/libpitaya-cluster/cpp-lib/deps/etcd-cpp-apiv3

  does not contain a CMakeLists.txt file.

-- Found OpenSSL: /Users/admin/.conan/data/OpenSSL/1.0.2o/conan/stable/package/75c89fa3e1091e5c3911f9847d6d4abd7c60e60f/lib/libcrypto.a (found version "1.0.2o")  
CMake Warning (dev) at deps/cnats-1.8.0/CMakeLists.txt:62 (set):
  implicitly converting 'FILE' to 'STRING' type.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Setting library to MODULE
-- Setting properties for MacOSX bundle
-- Configuring incomplete, errors occurred!
See also "/code/src/github.com/topfreegames/libpitaya-cluster/cpp-lib/_builds/mac-unity/CMakeFiles/CMakeOutput.log".
make: *** [build-mac-unity] Error 1
felipejfc commented 5 years ago

hi @jmesyan you don't really need to build the plugins by yourself to run the examples, it's already built here https://github.com/topfreegames/libpitaya-cluster/tree/master/unity-example/Assets/Plugins, also, for using libpitaya-cluster into your project you can use the official nuget package https://www.nuget.org/packages/LibPitayaServerCpp/

ghost commented 5 years ago

hi @felipejfc ,now the unity didn't report any bug, but when I click the button,the unity crashed, I am not familiar with unity, I intend to give up the test temporary, thank you for your help, do you have other library for layabox or cocos creator?

felipejfc commented 5 years ago

Can you better describe your use case for this lib? we don't officially support layabox or cocos creator but as it's a c++ library you could create the bindings yourself...

ghost commented 5 years ago

hi @felipejfc , I can't find any detail log when the unity is crashed, so I change the unity version to 2017.4.0f1 , use the old version code, and run the go-server. click the init libpitaya button, it is ok, but click the sendrpc button, run the error below and can't find any message in the console, could you tell me how to fixed it:

ERRO[0552] server 984539ee-c22a-4635-8e73-a55d0513cf95 doesn't have a grpc-host specified in metadata  source=pitaya
felipejfc commented 5 years ago

This shouldn't happen if you use the version from the master, can you try?