Exemple #1
0
        public static ServerToClientRpcCommandBuilder Broadcast <T>(T packet) where T : struct, IComponentData
        {
            var builder = new ServerToClientRpcCommandBuilder();

            builder.AddComponentData(packet)
            .AddComponentData(new SendRpcCommandRequestComponent());     // if there is no TargetConnection, it will be broadcasted
            //.SetName($"BroadcastRpcCommand {typeof(T).Name}");
            return(builder);
        }
Exemple #2
0
        public static ServerToClientRpcCommandBuilder SendTo <T>(Entity serverToClientConnection, T command) where T : struct, IComponentData
        {
            var builder = new ServerToClientRpcCommandBuilder();

            builder.AddComponentData(command)
            .AddComponentData(new SendRpcCommandRequestComponent {
                TargetConnection = serverToClientConnection
            });
            //.SetName($"RpcCommand {typeof(T).Name}");
            return(builder);
        }
Exemple #3
0
        public static ServerToClientRpcCommandBuilder SendTo <T>(int networkConnectionId, T packet) where T : struct, IComponentData
        {
            var connection = ServerManager.Instance.GetClientConnectionByNetworkId(networkConnectionId);

            if (connection.IsEmpty)
            {
                throw new ClientConnectionNotFoundException($"No connection with network id [{networkConnectionId}] found");
            }

            var builder = new ServerToClientRpcCommandBuilder();

            builder.AddComponentData(packet)
            .AddComponentData(new SendRpcCommandRequestComponent {
                TargetConnection = connection.connectionEntity
            });
            //.SetName($"RpcCommand {typeof(T).Name}");
            return(builder);
        }