Пример #1
0
        private static void OnSendAvatarStreamsToClientMessageReceived(SendAvatarStreamsToClientMessage message)
        {
            AvatarStreamMessage                avatarStreamMessage = new AvatarStreamMessage();
            LogicArrayList <LogicLong>         ids = message.StreamIds;
            LogicArrayList <AvatarStreamEntry> avatarStreamList = new LogicArrayList <AvatarStreamEntry>(ids.Size());

            for (int i = 0; i < ids.Size(); i++)
            {
                AvatarStreamEntry avatarStreamEntry = StreamManager.GetAvatarStream(ids[i]);

                if (avatarStreamEntry != null)
                {
                    avatarStreamList.Add(avatarStreamEntry);
                }
            }

            avatarStreamMessage.SetStreamEntries(avatarStreamList);
            avatarStreamMessage.Encode();

            ServerMessageManager.SendMessage(StreamMessageManager.CreateForwardLogicMessage(avatarStreamMessage, message.SessionId), ServerManager.GetProxySocket(message.SessionId));

            for (int i = 0; i < avatarStreamList.Size(); i++)
            {
                AvatarStreamEntry avatarStreamEntry = avatarStreamList[i];

                if (avatarStreamEntry.IsNew())
                {
                    avatarStreamEntry.SetNew(false);
                    StreamManager.Save(avatarStreamEntry);
                }
            }
        }
Пример #2
0
        private static void OnForwardLogicMessageRequestMessageReceived(ForwardLogicRequestMessage message)
        {
            PiranhaMessage logicMessage = LogicMagicMessageFactory.Instance.CreateMessageByType(message.MessageType);

            if (logicMessage == null)
            {
                throw new Exception("logicMessage should not be NULL!");
            }

            logicMessage.GetByteStream().SetByteArray(message.MessageBytes, message.MessageLength);
            logicMessage.SetMessageVersion(message.MessageVersion);
            logicMessage.Decode();

            if (!logicMessage.IsServerToClientMessage())
            {
                switch (logicMessage.GetMessageType())
                {
                case AskForAllianceDataMessage.MESSAGE_TYPE:
                    AskForAllianceDataMessage askForAllianceDataMessage = (AskForAllianceDataMessage)logicMessage;
                    LogicLong allianceId = askForAllianceDataMessage.RemoveAllianceId();

                    if (AllianceManager.TryGet(allianceId, out Alliance alliance))
                    {
                        ServerMessageManager.SendMessage(StreamMessageManager.CreateForwardLogicMessage(alliance.GetAllianceDataMessage(), message.SessionId),
                                                         ServerManager.GetProxySocket(message.SessionId));
                    }

                    break;
                }
            }
        }