jpcsupplies / Economy_mod

Basic Economy System for Space Engineers
13 stars 12 forks source link

Server/Client communication #22

Closed midspace closed 9 years ago

midspace commented 9 years ago

I've been reworking the code as a separate branch to get Client/Server comms working.

An explanation on the 'client side'.

The Mod API code runs all client and servers simultaneously. There isn't a specific module for servers or for clients.

To make this work, you actually have to write your own logic to check if the mod is running on a server or a client. And in the case of a Host (listen server), it is running BOTH! Otherwise, you would end up with each player creating a and loading a balance file on their own computer.

ie... am I a server? -- then read the bank records. -- set up listen hooks for commands from clients.

am I a client? -- set up listen hooks for commands from server. -- set up chat hooks for instructions from user.

The flow: -- user enters a chat command "/bal". -- client examines the command for what the user wants, and either responds directly (if it already has what it needs), or asks the server for detail. -- client sends special message instruction to server. -- server receives message instruction. -- server disseminates message instruction. -- server runs the Balance Message for the user specified. -- server sends Balance Response instruction to client. -- client receives message instruction. -- client disseminates message instruction. -- client displays balance on screen to user.

What I've written just covers the loading, reading, and writing of the file. There isn't any server/client comms to separate this portion of the code.


This what I've done so far published as a test mod. http://steamcommunity.com/sharedfiles/filedetails/?id=515710178

It is currently working.

I haven't actually tested it with two players as yet, or on a dedicated server. But I'm hopeful. :)

It does logging only on the server side. It will save the bank balances only on the server side.

jpcsupplies commented 9 years ago

ok will try it here now any particular commands ?

jpcsupplies commented 9 years ago

oh i see its a clone of the main git ok test results -

peer hosting - host can see balance, most commands work peer hosting - client can use help commands and get pop up but no other commands work, or crash the client

DS hosting - admin can see help commands but no other commands seen responsive

logs https://gist.github.com/jpcsupplies/6e169c296faade69570d

midspace commented 9 years ago

I've updated the test mod to address the issues, and it's working now.

jpcsupplies commented 9 years ago

ok will retest when i get home, looking promising :)

midspace commented 9 years ago

My Fork is ready to merge in. https://github.com/midspace/Economy_mod

jpcsupplies commented 9 years ago

ok ill finish my sync and try to merge it..

.. just as soon as i figure out how to merge that is lol oops

midspace commented 9 years ago

Complete with https://github.com/jpcsupplies/Economy_mod/commit/15cc91a5254ffa033359c463ee2937748ffd94c1