Beispiel #1
0
 public void MsgtoSer_Welcome(NetworkConnection conn, Msg_Welcome msg)
 {
     H.klog1($"Server got a msgSer from {conn.connectionId} => {msg.wlcomemsg}", this.name);
     if (msg.fabid != "")
     {
         _knet.UpdateFabidForConn(conn.connectionId, msg.fabid);
     }
 }
Beispiel #2
0
 public void MsgtoCli_Welcome(Msg_Welcome msg)
 {
     H.klog1($"Client got a msgSer from Server => {msg.wlcomemsg} and myconnid {msg.cliconnid}", this.name);
     AssistMan._ins.myCliConnId = msg.cliconnid;
     // setup conn id on _myIden if this client is login and authenticated
     if (FabAuthenCodeNLogin.authenNverified)
     {
         fabAuthen.SetCliConnid(msg.cliconnid);
     }
 }
Beispiel #3
0
    /// <summary>
    /// Called on the server when a new client connects.
    /// <para>Unity calls this on the Server when a Client connects to the Server. Use an override to tell the NetworkManager what to do when a client connects to the server.</para>
    /// </summary>
    /// <param name="conn">Connection from client.</param>
    public override void OnServerConnect(NetworkConnection conn)
    {
        H.klog1($"Server Getting a Connection from client {conn}", this.name);

        AddCliOnConnect(conn);

        // sending not ready msg
        NetworkServer.SetClientNotReady(conn);
        Msg_Welcome msgtocli = new Msg_Welcome {
            wlcomemsg = $"Hey , my friends {conn.connectionId}", cliconnid = conn.connectionId
        };

        conn.Send(msgtocli);
        Msg_Maintenance msgMaintenance = new Msg_Maintenance {
            maintenTime = DateTime.Now
        };

        conn.Send(msgMaintenance);
    }
Beispiel #4
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);
    }