예제 #1
0
        /// <summary>
        ///
        /// </summary>
        public void CharacterSignOut(string account, CharacterObject character)
        {
            if (!friendList.ContainsKey(account))
            {
                return;
            }

            friendList[account].Remove(character);

            NetworkObject characterSignOut = new NetworkObject();

            characterSignOut.AddField(0, NetworkObjectField.CreateIntField((int)ServerFriendAction.SignOut));
            characterSignOut.AddField(1, NetworkObjectField.CreateStringField(account));
            characterSignOut.AddField(2, NetworkObjectField.CreateObjectField(character.ToNetworkObject()));
            owner.EnqueuePacket(new ServerObjectPacket(ObjectOpcode.FriendList, characterSignOut, false));
        }
예제 #2
0
        /// <summary>
        /// Broadcast text message from <see cref="CharacterObject"/> to all members.
        /// </summary>
        public void BroadcastMessage(CharacterObject character, string message)
        {
            if (!HasMember(character))
            {
                return;
            }

            var channelMessage = new NetworkObject();

            channelMessage.AddField(0, NetworkObjectField.CreateIntField((int)ServerChannelAction.Message));
            channelMessage.AddField(1, NetworkObjectField.CreateObjectField(character.ToNetworkObject()));
            channelMessage.AddField(2, NetworkObjectField.CreateStringField(name));
            channelMessage.AddField(3, NetworkObjectField.CreateStringField(message));
            channelMessage.AddField(4, NetworkObjectField.CreateStringField(GetShortcut()));
            BroadcastMessage(ObjectOpcode.Channel, channelMessage);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        public void CharacterSignIn(string account, CharacterObject character)
        {
            if (!friendList.ContainsKey(account))
            {
                return;
            }

            friendList[account].Add(character);

            NetworkObject characterSignIn = new NetworkObject();

            characterSignIn.AddField(0, NetworkObjectField.CreateIntField((int)ServerFriendAction.SignIn));
            characterSignIn.AddField(1, NetworkObjectField.CreateStringField(account));
            characterSignIn.AddField(2, NetworkObjectField.CreateObjectField(character.ToNetworkObject()));
            owner.EnqueueMessage(ObjectOpcode.FriendList, characterSignIn);
        }
예제 #4
0
        protected override void OnAddMember(CharacterObject character)
        {
            Session session = NetworkManager.FindSessionByCharacter(character);

            if (session == null)
            {
                return;
            }

            NetworkObject fellowshipJoin = new NetworkObject();

            fellowshipJoin.AddField(0, NetworkObjectField.CreateIntField((int)FellowshipAction.Join));
            fellowshipJoin.AddField(1, NetworkObjectField.CreateObjectField(Info.ToNetworkObject()));
            session.EnqueueMessage(ObjectOpcode.Fellowship, fellowshipJoin);

            // send existing members to new member
            foreach (CharacterObject existingCharacter in members.Values)
            {
                NetworkObject fellowshipMemberJoinExisting = new NetworkObject();
                fellowshipMemberJoinExisting.AddField(0, NetworkObjectField.CreateIntField((int)FellowshipAction.MemberJoin));
                fellowshipMemberJoinExisting.AddField(1, NetworkObjectField.CreateObjectField(Info.ToNetworkObject()));
                fellowshipMemberJoinExisting.AddField(2, NetworkObjectField.CreateObjectField(existingCharacter.ToNetworkObject()));
                session.EnqueueMessage(ObjectOpcode.Fellowship, fellowshipMemberJoinExisting);
            }

            members.Add(character.Sequence, character);
            session.Fellowships.Add(this);

            // send new member to existing members
            NetworkObject fellowshipMemberJoin = new NetworkObject();

            fellowshipMemberJoin.AddField(0, NetworkObjectField.CreateIntField((int)FellowshipAction.MemberJoin));
            fellowshipMemberJoin.AddField(1, NetworkObjectField.CreateObjectField(Info.ToNetworkObject()));
            fellowshipMemberJoin.AddField(2, NetworkObjectField.CreateObjectField(character.ToNetworkObject()));
            BroadcastMessage(ObjectOpcode.Fellowship, fellowshipMemberJoin);
        }