Пример #1
0
        private static void RequestPlayerObject()
        {
            // Ready/AddPlayer is usually triggered by a scene load completing. if no scene was loaded, then Ready/AddPlayer it here instead.
            if (!NetworkClient.ready)
            {
                NetworkClient.Ready();
            }

            NetworkClient.AddPlayer();
            clientHasPlayer = true;

            Logger.Debug("Client has requested player object.");
        }
        public override void OnClientConnect(NetworkConnection conn)
        {
            if (!clientLoadedScene)
            {
                if (!NetworkClient.ready)
                {
                    NetworkClient.Ready();
                }
                NetworkClient.AddPlayer();
            }

            ClientConnected?.Invoke();
        }
Пример #3
0
 private void Start()
 {
     Boton.onClick.AddListener(delegate()
     {
         if (NetworkClient.AddPlayer())
         {
             Room.SetDebugText("Esperando al resto de jugadores...", disappear: false);
             Boton.interactable = false;
         }
         else
         {
             Room.SetDebugText("Error al enviar mensaje al servidor", disappear: true);
             Boton.interactable = true;
         }
     }
                               );
 }
Пример #4
0
 public override void OnClientConnect(NetworkConnection conn)
 {
     Debug.Log("New client has connected");
     // OnClientConnect by default calls AddPlayer but it should not do
     // that when we have online/offline scenes. so we need the
     // clientLoadedScene flag to prevent it.
     if (!clientLoadedScene)
     {
         // Ready/AddPlayer is usually triggered by a scene load
         // completing. if no scene was loaded, then Ready/AddPlayer it
         // here instead.
         if (!NetworkClient.ready)
         {
             NetworkClient.Ready();
         }
         if (autoCreatePlayer)
         {
             NetworkClient.AddPlayer();
         }
     }
 }
Пример #5
0
    /// <summary>
    /// Called on the client when connected to a server.
    /// <para>The default implementation of this function sets the client as ready and adds a player. Override the function to dictate what happens when the client connects.</para>
    /// </summary>
    /// <param name="conn">Connection to the server.</param>
    public override void OnClientConnect(NetworkConnection serconn)
    {
        H.klog1($"client successful connected to server", this.name);
        //Caching ConntoServer, so we can send msg to server
        AssistMan._ins.conntoserver = serconn;
        AssistMan._ins.onCliConnect?.Invoke(true);
        // We will disable auto ready here --------
        //---       BASE ON CLIENT CONNECT
        // OnClientConnect by default calls AddPlayer but it should not do
        // that when we have online/offline scenes. so we need the
        // clientLoadedScene flag to prevent it.
        if (!clientLoadedScene)
        {
            // Ready/AddPlayer is usually triggered by a scene load
            // completing. if no scene was loaded, then Ready/AddPlayer it
            // here instead.
            //===>    //***    if (!NetworkClient.ready) NetworkClient.Ready();********************
            if (autoCreatePlayer)
            {
                NetworkClient.AddPlayer();
            }
        }
        //H.klog($"This is using _ins of Fabauthen {FabAuthenCodeNLogin._ins.GetCliFabid()}");
        //H.klog($"This is using Fabauthen obj {fabAuthen.GetCliFabid()}");

        //base.OnClientConnect(conn);
        // ----     END BASE ON CLIENT CONNECT
        //sending welcome msg to server and also fabid
        Msg_Welcome msg = new Msg_Welcome {
            wlcomemsg = $"Hello anal server + fabid {fabAuthen.GetCliFabid()}"
        };

        msg.fabid = (fabAuthen.GetCliFabid() != null) ? fabAuthen.GetCliFabid() : "";
        //msg.fabid = "testfabid";
        serconn.Send(msg);
    }