a simple demo of command synchronization with frontend use unity and backend use go
- use unity websocket to connect to go server
- send command like
<action>|<arg1>,<arg2>,<arg3>,...
to server - server according to the command to do the corresponding action
- unity receive the result from server and do some dispose
to run this demo, you need to install unity and go
you need to import 'Standard Assets' from Unity Asset Store.
at least, you need to import all the packages in 'Standard Assets' except '2D'.
and you need to install 'Cinemachine' from Unity Asset Store.
you need to install go and set the GOPATH
and need to install gnet package
go get github.com/panjf2000/gnet
then, you build the server
go build main.go server.go
and run the server
./main
when command line show like following, it means the server is running
2022/09/21 15:04:29 Game server is listening on [::]:9000 (multi-cores: true, loops: 12)
then you can run unity client to connect the server