public override void Server_ReceiveMessage(int connectionID, ByteStream msgData, LLServer server)
        {
            int    teamNumber = msgData.PopInt32();
            string message    = msgData.PopString();

            var targetsList = new List <int>();

            foreach (var userPair in server.NetUsers)
            {
                NetUser netUser = userPair.Value;

                if (netUser.teamNumber == teamNumber && netUser.connectionID != connectionID)
                {
                    targetsList.Add(netUser.connectionID);
                }
            }

            int[] targets = targetsList.ToArray();

            var byteStream = new ByteStream();

            byteStream.Append((byte)NetMessageType.ChatTeamMessage);
            byteStream.Append(teamNumber);
            byteStream.Append(message);

            server.MulticastNetMessage(targets, server.ReliableChannel, byteStream.ToArray());
        }
Exemplo n.º 2
0
        public override void Server_ReceiveMessage(int connectionID, ByteStream msgData, LLServer server)
        {
            int    target  = msgData.PopInt32();
            string message = msgData.PopString();

            ByteStream byteStream = new ByteStream();

            byteStream.Append((byte)NetMessageType.ChatWhisper);
            byteStream.Append(connectionID);
            byteStream.Append(message);

            server.SendNetMessage(target, server.ReliableChannel, byteStream.ToArray());
        }
Exemplo n.º 3
0
        public override void Server_ReceiveMessage(int connectionId, ByteStream data, LLServer server)
        {
            try
            {
                // Update Current user Data
                var meUser = server.NetUsers[connectionId];
                meUser.UserName   = data.PopString();
                meUser.TeamNumber = data.PopInt32();

                ByteStream msg = new ByteStream();
                msg.Encode
                (
                    (byte)NetMessageType.USER_INFO,
                    connectionId,
                    meUser.UserName,
                    meUser.TeamNumber
                );

                // Broadcast this user info to other users
                server.BroadcastNetMessage(server.ReliableChannel, msg.ToArray(), connectionId);

                // Send currently connected users data to this user
                // The message here include the position and rotation to proper spawn the player
                foreach (var user in server.NetUsers)
                {
                    if (user.Key == connectionId)
                    {
                        continue;
                    }
                    msg = new ByteStream();
                    msg.Encode
                    (
                        (byte)NetMessageType.USER_INFO_SPAWNPOSITION,
                        user.Key,
                        user.Value.UserName,
                        user.Value.TeamNumber,
                        server.PlayerInstances[user.Key].transform.position,
                        server.PlayerInstances[user.Key].transform.rotation
                    );
                    server.SendNetMessage(connectionId, server.ReliableChannel, msg.ToArray());
                }
                Debug.Log($"@Server -> @UserInfo: User [ID: {connectionId} , UN:{meUser.UserName} , T:{meUser.TeamNumber} ] Registered");
            }
            catch (Exception e)
            {
                Debug.LogError($"@Server -> @OnUserInfo: [{e.Message}]");
            }
        }
Exemplo n.º 4
0
 public abstract void Server_ReceiveMessage(int connectionID, ByteStream msgData, LLServer server);
 public override void Server_ReceiveMessage(int connectionID, ByteStream msgData, LLServer server)
 {
     server.DisconnectUser(connectionID);
 }
Exemplo n.º 6
0
        public override void Server_ReceiveMessage(int connectionID, ByteStream msgData, LLServer server)
        {
            string userName   = msgData.PopString();
            int    teamNumber = msgData.PopInt32();

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

            server.NetUsers[connectionID] = netUser;

            var byteStream = new ByteStream();

            byteStream.Append((byte)NetMessageType.UserInfo);
            byteStream.Append(connectionID);
            byteStream.Append(userName);
            byteStream.Append(teamNumber);

            server.BroadcastNetMessage(server.ReliableChannel, byteStream.ToArray(), connectionID);

            byteStream.ResetBuffer();
            byteStream.Append((byte)NetMessageType.SpawnCharacter);
            byteStream.Append(connectionID);

            server.BroadcastNetMessage(server.ReliableChannel, byteStream.ToArray(), connectionID);


            foreach (var serverNetUser in server.NetUsers)
            {
                NetUser other = serverNetUser.Value;

                byteStream.ResetBuffer();

                byteStream.Append((byte)NetMessageType.UserInfo);
                byteStream.Append(other.connectionID);
                byteStream.Append(other.userName);
                byteStream.Append(other.teamNumber);

                server.SendNetMessage(connectionID, server.ReliableChannel, byteStream.ToArray());

                if (other.connectionID == connectionID)
                {
                    continue;
                }

                byteStream.ResetBuffer();
                byteStream.Append((byte)NetMessageType.SpawnCharacter);
                byteStream.Append(other.connectionID);

                server.SendNetMessage(connectionID, server.ReliableChannel, byteStream.ToArray());
            }
        }
Exemplo n.º 7
0
 public override void Server_ReceiveMessage(int connectionId, ByteStream data, LLServer server)
 {
     // Only Client - Set the spawn position for the players connected before thee current client
 }
Exemplo n.º 8
0
 public override void Server_ReceiveMessage(int connectionId, ByteStream data, LLServer server)
 {
     // Only Client
 }
Exemplo n.º 9
0
        public override void Server_ReceiveMessage(int connectionID, ByteStream msgData, LLServer server)
        {
            string userName   = msgData.PopString();
            int    teamNumber = msgData.PopInt32();

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

            server.NetUsers[connectionID] = netUser;
        }
Exemplo n.º 10
0
        public override void Server_ReceiveMessage(int connectionID, ByteStream msgData, LLServer server)
        {
            var byteStream = new ByteStream();

            byteStream.Append((byte)NetMessageType.ChatBroadcast);

            string message = msgData.PopString();

            byteStream.Append(message);

            server.BroadcastNetMessage(server.ReliableChannel, byteStream.ToArray(), connectionID);
        }
Exemplo n.º 11
0
 public override void Server_ReceiveMessage(int connectionId, ByteStream data, LLServer server)
 {
     try
     {
         int targetId = data.PopInt32();
         data.Append(connectionId);
         server.SendNetMessage(targetId, server.ReliableChannel, data.ToArray());
     }
     catch (Exception e)
     {
         Debug.LogError($"@Server -> @ChatWhisper: [{e.Message}]");
     }
 }
Exemplo n.º 12
0
 public override void Server_ReceiveMessage(int connectionId, ByteStream data, LLServer server)
 {
     data.Append(connectionId);
     // Get all teammates
     int[] targets = server.NetUsers.Where(x => x.Value.TeamNumber == server.NetUsers[connectionId].TeamNumber)
                     .Select(x => x.Key)
                     .ToArray();
     server.MulticastNetMessage(targets, server.ReliableChannel, data.ToArray(), connectionId);
 }
Exemplo n.º 13
0
        public override void Server_ReceiveMessage(int connectionId, ByteStream data, LLServer server)
        {
            try
            {
                // Get the destination vector and set on the right player instance
                Vector3 destination = data.PopVector3();
                server.PlayerInstances[connectionId].SetDestination(destination);

                data = new ByteStream();
                data.Encode
                (
                    (byte)NetMessageType.GAMEPLAY_SETDESTINATION,
                    connectionId,
                    destination
                );
                // Broadcast this user info to other users
                server.BroadcastNetMessage(server.ReliableChannel, data.ToArray(), connectionId);
            }
            catch (Exception e)
            {
                Debug.LogError($"@Client -> @ConnectionAck: [{e.Message}]");
            }
        }
Exemplo n.º 14
0
 public override void Server_ReceiveMessage(int connectionId, ByteStream data, LLServer server)
 {
     try
     {
         data.Append(connectionId);
         server.BroadcastNetMessage(server.ReliableChannel, data.ToArray(), connectionId);
     }
     catch (Exception e)
     {
         Debug.LogError($"@Server -> @ChatBroadcast: [{e.Message}]");
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// Sends the information to all clients of a character that requires to be moved
        /// </summary>
        /// <param name="connectionID"></param>
        /// <param name="msgData"></param>
        /// <param name="server"></param>
        public override void Server_ReceiveMessage(int connectionID, ByteStream msgData, LLServer server)
        {
            NetUser netUser = server.NetUsers[connectionID];

            netUser.targetPos = msgData.PopVector3();

            server.NetUsers[connectionID] = netUser;

            msgData.ResetBuffer();

            msgData.Append((byte)NetMessageType.CharacterMove);
            msgData.Append(connectionID);
            msgData.Append(netUser.targetPos);

            server.BroadcastNetMessage(server.ReliableChannel, msgData.ToArray(), connectionID);
        }