I also noticed that the update receives the NetworkEventType and in that switch statement you decide how to reply accordingly to the request. I have the following questions :
How to add my own network event types like “Login, GetRooms, CreateRoom, JoinRoom etc etc”
If I am using the LLAPI do I have to pay Unity anything ?
For my server can it just be an unity exe that just runs so the update will work. I saw articles on headless mode etc etc but I will be getting a windows machine.
I have afew more questions but I will have to investigate further before posting a question here.
Thanks
I made another level of abstraction and just used the Data event to message.
This goes inside the loop waiting for events on my ServerNetworkManager.cs,
case NetworkEventType.DataEvent:
if (connectionsIds.Contains(connectionId)) {
Stream stream = new MemoryStream(msgInBuffer);
BinaryFormatter f = new BinaryFormatter();
string message = (string)f.Deserialize(stream);
//Debug.Log("Server: Client " + connectionId.ToString() + " data sent: " + message);
OnStatusToParse(message);
}
break;
As you see, i call OnStatusToParse(string message);
It is a delegate
public delegate void StatusHandler(string s);
public static event StatusHandler OnStatusToParse;
An then i have a ServerEventHandler.cs and i have something like this,
void Start()
{
ServerNetworkManager.OnStatusToParse += ClientStatusRecieved;
}
public void ClientStatusRecieved(string s)
{
Message status = JsonToMessage(s);
switch (status.data)
{
case "Idle":
//OnIdle();
Debug.Log("Client is on idle status");
break;;
case "Error":
OnClientError();
break;
case "Connected":
OnConected();
Debug.Log("Client connected");
case "Disconnected":
OnDisconected();
Debug.Log("Client disconnected");
break;
}
And all that funcions On…() being delegates aswell
public delegate void StatusHandle();
public static event StatusHandle OnIdle;
public static event StatusHandle OnConected;
public static event StatusHandle OnDisconected;
public static event StatusHandle OnClientError;
I hope it works on you to make an idea. I can’t answer the other ones sorry.
My game will be made for (iOS, Android and windows PC) its a basic game that contains 4 players per room.
The room will just be an object created in Memory so basically “var room = new Room()” then it will automatically create a GUID as an ID and you can then go room.AddPlayer(PassInPlayer). I dont need to store the rooms because if a play leaves a room, the game is over, You cant play this game with 3 people, game needs 4 people. I will store player details in a sql database (username password pic etc etc) This will be my login system. List rooms will just display a List to the client. The server will deal cards to a room that has 4 players, this is when the game begins. All messages sent to the server will be (RoomID, PlayerID and CardID) so it will just be a basic JSON object. The rooms will be the matchmaking I assume so I dont need Unitys matchmaker. The server will be hosted in the cloud so I dont need PAT punchthrough I would think. Now using LLAPI I wont be payin unity anything, Is this the right way to achieve my goal or should I be using NetworkServerSimple and will I pay unity for anything using NetworkServerSimple. I just need to send ints from my server to my clients and back to the server.
I think llapi works for you just fine. All the clients make a connect and wait for orders from server, then they parse this orders and render something, then the server waits for client satus etc.
Make a good planing first after start coding and you will be fine.
I am planning to have a master server, the server will send the ints down to each player, and the server will request a player to send an int back, its kinda turned based meaning the server will determine which order the players send an int up so maybe 1 round the server will say ok "Player 1 plays 1st, then Player 2 etc etc) then the sever will get those ints in that order for that RoomID, the server will decide who won the round, the winner will be prompted to play first in the next round and so on… Its turn based but real time if you know what I mean…The game will probably last about 30mins ±. The server will determine the score and send it down to the clients.