#Just want to make sure I understand the room architecture

80 messages · Page 1 of 1 (latest)

wild flower
#

I'm going to be hosting a dedicated server on the cloud, from this instance I will be managing and handling all my games (100 games per instance, with 4 clients connecting to each game).

If I understand correctly would the term of hosting these games be rooms in Mirror? If that's the case, when a player joins a room and I send a message could I also assume SendToAll will only send to the clients inside that room?

Because SendToAll to me means that it sends to all connected clients so every client connected to that instance will receive a message.

Are channelIds the "Rooms": void NetworkClient.Send<NetworkPlayerHealth>(NetworkPlayerHealth message, [int channelId = 0])

rare ingot
wild flower
rare ingot
#

SendToReadyObservers is probably what you want, as that takes a NI as param and only sends to observers of that client

rare ingot
wild flower
#

Interest Management seems to cover a MMO type game, that's not what specifically I'm after.

#

I want to have 8 players connect to an instance of a game, then 8 more to another instance.

#

eg, two seperate games with their own logic.

#

But there's no match API

rare ingot
#

Match Interest Management is intended for non-physics games like card, board, arcade games. Is that what you want?

wild flower
rare ingot
rare ingot
#

Although once you have players in a match, ClientRpc is easier to use.

wild flower
rare ingot
wild flower
rare ingot
wild flower
#
public void StartClient()
{
    if (NetworkClient.active)
    {
        Debug.LogWarning("Client already started.");
        return;
    }


    NetworkClient.RegisterHandler<PlayerHealthMessage>(HandleNetworkMessage);
    NetworkClient.RegisterHandler<RejectMessage>(OnClientRejectionMessage);
    NetworkClient.OnConnectedEvent = OnClientConnected;
    NetworkClient.OnDisconnectedEvent = OnClientDisconnected;
    NetworkClient.OnErrorEvent = OnClientError;

    // Application.runInBackground = true; TODO: find out what this is

    if (string.IsNullOrWhiteSpace(networkAddress))
    {
        Debug.LogError("Set address");
        return;
    }

    Transport.active = networkTransportSystem.Transport;
    NetworkClient.Connect(networkAddress);
}

rare ingot
#

Match Int Mgmt depends on the presence of the components

wild flower
rare ingot
#

hmm?

wild flower
#

So you guys are just setting a hashmap with the connections?

readonly HashSet<NetworkConnectionToClient> newObservers =
            new HashSet<NetworkConnectionToClient>();
rare ingot
#

That's in the abstract class, yes

#

The derived classes use that, each one does different things with that

wild flower
# rare ingot

This dones't make a lot of sense to me, I don't know why you would grab a get component on update. or why this would be a component. So I'm a little confused with it.

Just so I can understand the functionality, this is what I think I will be able to find after reading more of the source.

I'll need to set a identity, then get the NetworkConnectionToClient observers and that's basically it?

#
    private void OnServerConnectInternal(NetworkConnectionToClient client)
    {
        Debug.Log("OnServerConnectInternal");
        if (!NetworkServer.active && canClientConnect)
        {
            var rejectionMessage = new RejectMessage { value = ServerRejections.ServerNotStarted };
            client.Send(rejectionMessage);
            client.Disconnect();
            return;
        }

        if (!CanConnect(client))
        {
            var rejectionMessage = new RejectMessage { value = ServerRejections.Banned };
            client.Send(rejectionMessage);
            client.Disconnect();
            return;
        }

        client.observing = 

This correct?

rare ingot
# wild flower This dones't make a lot of sense to me, I don't know why you would grab a get co...

We need to discover any object that has joined a match or changed match id's to update relevant match observers

I don't know why you would grab a get component on update. or why this would be a component.
It's a component because Unity is component driven. Users expect to have components where they can set values and see changes happen in the inspector, and because there could be things that are not part of matches, and have no match component

wild flower
#

But in terms of what I'm looking to do,

       protected void AddObserver(NetworkConnectionToClient connection, NetworkIdentity identity)
        {
            connection.AddToObserving(identity);
            identity.observers.Add(connection.connectionId, connection);
        }

This is pretty much it?

rare ingot
#

seems like it

wild flower
# rare ingot seems like it

Is this a bug for Guid in unity 2023?

    public class NetworkMatch : NetworkBehaviour
    {
        ///<summary>Set this to the same value on all networked objects that belong to a given match</summary>
        public Guid matchId;
    }
rare ingot
#

Unity has never serialized GUID's...dumb as that is

#

my recollection is you have to make a custom property drawer for it

wild flower
#

Okay so after reading the source, it's making sense to me.

I need to be able to send a message to a network match with a Guid, not sync a NetworkBehaviour, what would be the way to do that?

wild flower
#

I believe the only way I can do this is have my collections of clients on my end and then send them directly the message to their network id?

rare ingot
#

That could work too

wild flower
# rare ingot That could work too

Dumb question,

public struct Player : IComponentData
{
    public int NetworkId;
    public ulong Guid;
    public string Name;
}

Under the hood you're doing the same thing with the guid anyways right?

#

Basically grabbing all NetworkMatch identities and then sending the rpc / messages.

rare ingot
#

I'm sorry but I have limited time to support what you're doing here. We wrote Mirror as a high-level solution, and you're expected to use the systems and components as provided. Reinventing all that through network messages is a ton of work, and ignores all the work done so you don't have to do all that.

rare ingot
#

We don't at all

wild flower
rare ingot
#

We don't deal with ECS at all

wild flower
#

It's litterally all just data.

rare ingot
#

by ECS you're referring to Unity's Entity Component system and DOTS, which we don't support at all. You're on your own with that

wild flower
#

It doesn't matter what pattern I'm using.

#

You tell me not to use your API, I'm wading through your code to find a simple solution to sending a message through a network id.

#

A high level solution should exist.

rare ingot
#

Sure we support sending network messages, but not reinventing interest management to avoid components and not to wholesale avoid network behaviours

wild flower
#

Anyways thanks for your time, I see I'm not getting anywhere asking you advanced things.

rare ingot
#

NetworkIdentity.connectionToClient.Send

wild flower
#

Nothing, I'll figure it out, thanks.

rare ingot
rare ingot
rare ingot
wild flower
#

Understood, thank you.

rare ingot
#
public void Send<T>(T message, int channelId = Channels.Reliable)
            where T : struct, NetworkMessage
#

so if you have the NI, use the first one, if you have the client's conn, use that directly

wild flower
#
public struct Player : IComponentData
{
    public NetworkClient client;
    public int NetworkId;
    public ulong Guid;
    public string Name;
}

rare ingot
#

since NI.connectionToClient is only valid for networked objects spawned as owned by a client, e.g. a player object with an NI component, that you're apparently averse to, using NI probably won't suit you

wild flower
#

Really, thank you for your time. It helped.

rare ingot
wild flower
# rare ingot NetworkClient won't have any meaning on server - that's client side

No?

   private void OnServerConnectInternal(NetworkConnectionToClient client)
    {
        Debug.Log("OnServerConnectInternal");
        if (!NetworkServer.active && canClientConnect)
        {
            var rejectionMessage = new RejectMessage { value = ServerRejections.ServerNotStarted };
            client.Send(rejectionMessage);
            client.Disconnect();
            return;
        }

        if (!CanConnect(client))
        {
            var rejectionMessage = new RejectMessage { value = ServerRejections.Banned };
            client.Send(rejectionMessage);
            client.Disconnect();
            return;
        }
///This wouldn't work?
        StoreClientToECS(client);

        Debug.Log("OnServerConnectInternalValid");
        client.isAuthenticated = true;
rare ingot
#

that's NetworkConnectionToClient, not NetworkClient

wild flower
#

But you don't see anything wrong with my solution?

rare ingot
#

I was pointing it out in your struct

wild flower
rare ingot
#

In case it helps, NetworkServer has a dictionary of connections that's public