Exemplo n.º 1
0
    // Server function handlers --------------------------------------------------------------
    void OnServerClientConnected(NetworkMessage netmsg)
    {
        ClientInfoMsg clientInfo = netmsg.ReadMessage <ClientInfoMsg>();

        string clientID = clientInfo.clientIP + ":" + netmsg.conn.connectionId;

        if (clientList.ContainsKey(clientID))
        {
        }
        else
        {
            ClientInfo newClient = new ClientInfo();
            newClient.connID = netmsg.conn.connectionId;

            newClient.clientIP    = clientInfo.clientIP;
            newClient.hostName    = clientInfo.hostName;
            newClient.deviceModel = clientInfo.deviceModel;
            newClient.deviceType  = clientInfo.deviceType;
            newClient.instanceID  = 0;
            newClient.active      = true;

            Debug.Log("Client " + clientID + " connected to server");

            // Informs client of its server assigned connID
            ServerAssignmentMsg assignMsg = new ServerAssignmentMsg();
            assignMsg.connID = newClient.connID;
            SendTo(newClient.connID, ServerAssign, assignMsg);
        }
    }
Exemplo n.º 2
0
    private void OnServerReceiveClientInfo(NetworkMessage Msg)
    {
        if (Msg.conn.playerControllers.Count > 0)
        {
            PlayerController player = Msg.conn.playerControllers[0];
            if (player != null && player.gameObject != null)
            {
                JigsawPlayerController jigsawController = player.gameObject.GetComponent <JigsawPlayerController>();
                if (jigsawController != null)
                {
                    if (NetWorldState == null)
                    {
                        GenerateWorldState();
                    }
                    ClientInfoMsg     clientMsg   = Msg.ReadMessage <ClientInfoMsg>();
                    JigsawPlayerState playerState = NetWorldState.RegisterPlayer(clientMsg.Username);
                    jigsawController.PlayerState = playerState;
                    return;
                }
            }
        }
        ClientInfoMsg tmp = Msg.ReadMessage <ClientInfoMsg>();

        DeferredClientInfo.Add(Msg.conn.connectionId, tmp);
    }
Exemplo n.º 3
0
    //~ End server callbacks


    //~ Begin client callbacks
    public override void OnClientConnect(NetworkConnection conn)
    {
        base.OnClientConnect(conn);
        Debug.Log("Connected successfully to server, now to set up other stuff for the client...");

        ClientInfoMsg msg = new ClientInfoMsg();

        msg.Username = StaticJigsawData.LocalPlayerName;
        client.Send(JigsawNetworkMsg.ClientInfo, msg);
    }
Exemplo n.º 4
0
    // Client function handlers --------------------------------------------------------------
    void OnClientConnected(NetworkMessage netmsg)
    {
        Debug.Log("Client connected to server");

        ClientInfoMsg clientInfo = new ClientInfoMsg();

        clientInfo.clientIP    = localIP;
        clientInfo.hostName    = hostName;
        clientInfo.deviceType  = SystemInfo.deviceType.ToString();
        clientInfo.deviceModel = SystemInfo.deviceModel;
        netClient.Send(ClientConnect, clientInfo);

        connectState = ConnectState.Connected;
    }