Ejemplo n.º 1
0
        public override void Client_ReceiveMessage(ByteStream data, LLClient client)
        {
            try
            {
                int     conId  = data.PopInt32();
                NetUser meUser = new NetUser()
                {
                    ConnectionID = conId,
                    UserName     = client.UserName,
                    TeamNumber   = client.TeamNumber
                };
                client.NetUsers[conId] = meUser;
                client.MyConnectionId  = conId;

                data = new ByteStream();
                data.Encode
                (
                    (byte)NetMessageType.USER_INFO,
                    meUser.UserName,
                    meUser.TeamNumber
                );
                // Send USER_INFO message
                client.SendNetMessage(client.ReliableChannel, data.ToArray());
                // Spawn own player instance and flag it
                client.PlayerInstances[meUser.ConnectionID]        = NetSpawner.SpawnPlayer(Vector3.zero, Quaternion.identity);
                client.PlayerInstances[meUser.ConnectionID].IsMine = true;
                // Inject the client
                client.PlayerInstances[meUser.ConnectionID].SetClient(client);
            }
            catch (Exception e)
            {
                Debug.LogError($"@Client -> @ConnectionAck: [{e.Message}]");
            }
        }
        public override void Client_ReceiveMessage(ByteStream msgData, LLClient client)
        {
            int    teamNumber = msgData.PopInt32();
            string message    = msgData.PopString();

            client.AddMessageToQ($"Team_{teamNumber} >> {message}");
        }
Ejemplo n.º 3
0
        public override void Client_ReceiveMessage(ByteStream msgData, LLClient client)
        {
            string userName = client.UserName;
            string message  = msgData.PopString();

            client.AddMessageToQ($"{userName} >> {message}");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Moves the character of the clients specified by its connectionID to the position sent by the server
        /// </summary>
        /// <param name="msgData"></param>
        /// <param name="client"></param>
        public override void Client_ReceiveMessage(ByteStream msgData, LLClient client)
        {
            int     connectionID = msgData.PopInt32();
            Vector3 pos          = msgData.PopVector3();

            client.clientsCharacter[connectionID].MoveTo(pos);
        }
Ejemplo n.º 5
0
        public override void Client_ReceiveMessage(ByteStream msgData, LLClient client)
        {
            int    sender  = msgData.PopInt32();
            string message = msgData.PopString();

            string msg = $"< <[{client.NetUsers[sender].userName}]< <  {message}";

            client.AddMessageToQ(msg);
        }
Ejemplo n.º 6
0
        public override void Client_ReceiveMessage(ByteStream msgData, LLClient client)
        {
            int connectionID = msgData.PopInt32();

            NetUser netUser = client.NetUsers[client.myConnectionID];

            netUser.connectionID = connectionID;

            client.NetUsers[client.myConnectionID] = netUser;
            client.myConnectionID = connectionID;
        }
        /// <summary>
        /// Tells the local client to remove the specified client by its connectionID
        /// </summary>
        /// <param name="msgData"></param>
        /// <param name="client"></param>
        public override void Client_ReceiveMessage(ByteStream msgData, LLClient client)
        {
            int connectionID = msgData.PopInt32();

            if (client.NetUsers.ContainsKey(connectionID))
            {
                NetCharacterController netCharacterController = client.clientsCharacter[connectionID];
                Destroy(netCharacterController.gameObject);
                client.clientsCharacter.Remove(connectionID);

                client.NetUsers.Remove(connectionID);
            }
        }
 public override void Client_ReceiveMessage(ByteStream data, LLClient client)
 {
     try
     {
         string msg    = data.PopString();
         int    sender = data.PopInt32();
         client.AddMessageToQueue($"<<< TEAM [{client.NetUsers[sender].UserName}] {msg}");
     }
     catch (Exception e)
     {
         Debug.LogError($"@Client -> @ChatMulticast: [{e.Message}]");
     }
 }
Ejemplo n.º 9
0
 public override void Client_ReceiveMessage(ByteStream data, LLClient client)
 {
     try
     {
         // Get the destination vector and set on the right player instance
         int     conId       = data.PopInt32();
         Vector3 destination = data.PopVector3();
         client.PlayerInstances[conId].SetDestination(destination);
     }
     catch (Exception e)
     {
         Debug.LogError($"@Client -> @ConnectionAck: [{e.Message}]");
     }
 }
Ejemplo n.º 10
0
        public override void Client_ReceiveMessage(ByteStream msgData, LLClient client)
        {
            int    connectionID = msgData.PopInt32();
            string userName     = msgData.PopString();
            int    teamNumber   = msgData.PopInt32();

            var netUser = new NetUser
            {
                connectionID = connectionID,
                userName     = userName,
                teamNumber   = teamNumber
            };

            client.NetUsers[connectionID] = netUser;
        }
Ejemplo n.º 11
0
 public override void Client_ReceiveMessage(ByteStream data, LLClient client)
 {
     try
     {
         int conId = data.PopInt32();
         if (client.NetUsers.ContainsKey(conId) == false)
         {
             Debug.LogError("@Client -> @UserDisconnected: Trying to remove an Id that didn't exist");
             return;
         }
         client.NetUsers.Remove(conId);
         NetPlayer pInstance = client.PlayerInstances[conId];
         client.PlayerInstances.Remove(conId);
         Destroy(pInstance.gameObject);
     }
     catch (Exception e)
     {
         Debug.LogError($"@Client -> @UserDisconnected: [{e.Message}]");
     }
 }
Ejemplo n.º 12
0
        public override void Client_ReceiveMessage(ByteStream data, LLClient client)
        {
            try
            {
                int    conId    = data.PopInt32();
                string userName = data.PopString();
                int    teamNum  = data.PopInt32();

                var newUser = new NetUser()
                {
                    ConnectionID = conId,
                    UserName     = userName,
                    TeamNumber   = teamNum
                };
                client.NetUsers[conId]        = newUser;
                client.PlayerInstances[conId] = NetSpawner.SpawnPlayer(Vector3.zero, Quaternion.identity);
            }
            catch (Exception e)
            {
                Debug.LogError($"@Client -> @OnUserInfo: [{e.Message}]");
            }
        }
Ejemplo n.º 13
0
        public override void Client_ReceiveMessage(ByteStream data, LLClient client)
        {
            try
            {
                int        conId    = data.PopInt32();
                string     userName = data.PopString();
                int        teamNum  = data.PopInt32();
                Vector3    pos      = data.PopVector3();
                Quaternion rot      = data.PopQuaternion();

                var newUser = new NetUser()
                {
                    ConnectionID = conId,
                    UserName     = userName,
                    TeamNumber   = teamNum
                };
                client.NetUsers[newUser.ConnectionID]        = newUser;
                client.PlayerInstances[newUser.ConnectionID] = NetSpawner.SpawnPlayer(pos, rot);
            }
            catch (Exception e)
            {
                Debug.LogError($"@Client -> @OnUserInfo_SpawnPosition: [{e.Message}]");
            }
        }
Ejemplo n.º 14
0
 public abstract void Client_ReceiveMessage(ByteStream msgData, LLClient client);
Ejemplo n.º 15
0
        /// <summary>
        /// Tells the local client to spawn a character for the connection ID sent form the server
        /// </summary>
        /// <param name="msgData"></param>
        /// <param name="client"></param>
        public override void Client_ReceiveMessage(ByteStream msgData, LLClient client)
        {
            int connectionID = msgData.PopInt32();

            client.SpawnClientCharacter(connectionID);
        }
Ejemplo n.º 16
0
 public void SetClient(LLClient client)
 {
     _client = client;
 }