immali / go-altv

altv:mp api for go
4 stars 0 forks source link

Use channels #6

Open pixlcrashr opened 4 years ago

pixlcrashr commented 4 years ago

I am currently trying to understand your idea on the RPC system. In my understanding you are trying to create a TCP-server to send internal events to a client, right? We could use contexts for that. Furthermore, couldn't we even use the Module struct to provide all necessary server methods for alt:V - instead of creating a TCP server for regarding requests? Though, the TCP-server is localhost only, it slows down the requests that should be done.

Think about it. I am open for discussion.

immali commented 4 years ago

@TheMysteriousVincent The main reason I chose RPC is because I cannot call load additional go programs and let them connect to the Module. It always resulted in a pointer mess and everything crashed.

So my Idea was to start a RPC Server from the module (which can do stuff like spawn, etc.) and from here start all given resources. Those resources would be started with an argument id which they use to connect to the rpc server and send commands or receive.

As I'm currently not interested in GTA this repository is not under development. Ideas are welcome though

pixlcrashr commented 4 years ago

Thanks for the answer.

Thinking out of the box, wouldn't it be better in general to just compile custom code to a whole module (not resource)? Probably this would be the most efficent way, since Go is compiled to binary code anyway. Then you would also not have to mess around with sockets or channels.

Also you probably don't have to provide a C API wrapper since everything can be written, in fact, in Go using cGo (using "export Xyz" comments and library functions of cgo). Thus, it would be pretty easy to use: Import this repository somehow initialize the custom code with a given function of this repo and there you go.

Am I missing something?