Beispiel #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);
                }
            }
        }
Beispiel #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;
                }
            }
        }
Beispiel #3
0
        public override void OnReceiveSessionMessage(ServerSessionMessage message)
        {
            switch (message.GetMessageType())
            {
            case ServerMessageType.START_SERVER_SESSION:
                AllianceSessionManager.OnStartServerSessionMessageReceived((StartServerSessionMessage)message);
                break;

            case ServerMessageType.STOP_SERVER_SESSION:
                AllianceSessionManager.OnStopServerSessionMessageReceived((StopServerSessionMessage)message);
                break;

            case ServerMessageType.UPDATE_SOCKET_SERVER_SESSION:
                StreamMessageManager.OnUpdateSocketServerSessionMessageReceived((UpdateSocketServerSessionMessage)message);
                break;

            case ServerMessageType.FORWARD_LOGIC_MESSAGE:
                StreamMessageManager.OnForwardLogicMessageReceived((ForwardLogicMessage)message);
                break;

            case ServerMessageType.FORWARD_LOGIC_REQUEST_MESSAGE:
                StreamMessageManager.OnForwardLogicMessageRequestMessageReceived((ForwardLogicRequestMessage)message);
                break;

            case ServerMessageType.SEND_AVATAR_STREAMS_TO_CLIENT:
                StreamMessageManager.OnSendAvatarStreamsToClientMessageReceived((SendAvatarStreamsToClientMessage)message);
                break;
            }
        }
Beispiel #4
0
        public override void OnReceiveAccountMessage(ServerAccountMessage message)
        {
            switch (message.GetMessageType())
            {
            case ServerMessageType.LEAVE_ALLIANCE_MEMBER:
                StreamMessageManager.OnLeaveAllianceMemberMessageReceived((LeaveAllianceMemberMessage)message);
                break;

            case ServerMessageType.AVATAR_STREAM_SEEN:
                StreamMessageManager.OnAvatarStreamSeenMessageReceived((AvatarStreamSeenMessage)message);
                break;

            case ServerMessageType.REMOVE_AVATAR_STREAM:
                StreamMessageManager.OnRemoveAvatarStreamMessageReceived((RemoveAvatarStreamMessage)message);
                break;

            case ServerMessageType.ALLIANCE_AVATAR_CHANGES:
                StreamMessageManager.OnAllianceUpdateAvatarDataMessageReceived((AllianceAvatarChangesMessage)message);
                break;

            case ServerMessageType.ALLIANCE_CREATE_MAIL:
                StreamMessageManager.OnAllianceCreateMailMessageReceived((AllianceCreateMailMessage)message);
                break;

            case ServerMessageType.ALLIANCE_SHARE_REPLAY:
                StreamMessageManager.OnAllianceShareReplayMessageReceivedReceived((AllianceShareReplayMessage)message);
                break;

            case ServerMessageType.ALLIANCE_REQUEST_ALLIANCE_UNITS:
                StreamMessageManager.OnAllianceRequestAllianceUnitsMessageReceived((AllianceRequestAllianceUnitsMessage)message);
                break;

            case ServerMessageType.ALLIANCE_UNIT_DONATE_RESPONSE:
                StreamMessageManager.OnAllianceUnitDonateResponseMessageReceived((AllianceUnitDonateResponseMessage)message);
                break;

            case ServerMessageType.ALLIANCE_CHALLENGE_REQUEST:
                StreamMessageManager.OnAllianceChallengeRequestMessageReceived((AllianceChallengeRequestMessage)message);
                break;

            case ServerMessageType.ALLIANCE_CHALLENGE_REPORT:
                StreamMessageManager.OnAllianceChallengeReportMessageReceived((AllianceChallengeReportMessage)message);
                break;

            case ServerMessageType.ALLIANCE_CHALLENGE_LIVE_REPLAY_ID:
                StreamMessageManager.OnAllianceChallengeLiveReplayIdMessageReceived((AllianceChallengeLiveReplayIdMessage)message);
                break;

            case ServerMessageType.ALLIANCE_CHALLENGE_SPECTATOR_COUNT:
                StreamMessageManager.OnAllianceChallengeSpectatorCountMessageReceived((AllianceChallengeSpectatorCountMessage)message);
                break;
            }
        }
Beispiel #5
0
        public override void OnReceiveRequestMessage(ServerRequestMessage message)
        {
            switch (message.GetMessageType())
            {
            case ServerMessageType.CREATE_ALLIANCE_REQUEST:
                StreamMessageManager.OnCreateAllianceRequestMessageReceived((CreateAllianceRequestMessage)message);
                break;

            case ServerMessageType.ALLIANCE_JOIN_REQUEST:
                StreamMessageManager.OnAllianceJoinRequestMessageReceived((AllianceJoinRequestMessage)message);
                break;

            case ServerMessageType.CREATE_AVATAR_STREAM_REQUEST:
                StreamMessageManager.OnCreateAvatarStreamRequestMessageReceived((CreateAvatarStreamRequestMessage)message);
                break;

            case ServerMessageType.CREATE_REPLAY_STREAM_REQUEST:
                StreamMessageManager.OnCreateReplayStreamRequestMessageReceived((CreateReplayStreamRequestMessage)message);
                break;

            case ServerMessageType.LOAD_REPLAY_STREAM_REQUEST:
                StreamMessageManager.OnLoadReplayStreamRequestMessageReceived((LoadReplayStreamRequestMessage)message);
                break;

            case ServerMessageType.LOAD_AVATAR_STREAM_REQUEST:
                StreamMessageManager.OnLoadAvatarStreamRequestMessageReceived((LoadAvatarStreamRequestMessage)message);
                break;

            case ServerMessageType.LOAD_AVATAR_STREAM_OF_TYPE_REQUEST:
                StreamMessageManager.OnLoadAvatarStreamOfTypeRequestMessageReceived((LoadAvatarStreamOfTypeRequestMessage)message);
                break;

            case ServerMessageType.REQUEST_ALLIANCE_JOIN_REQUEST:
                StreamMessageManager.OnRequestAllianceJoinRequestMessageReceived((RequestAllianceJoinRequestMessage)message);
                break;
            }
        }