/// <summary>
        ///     Sends a <see cref="LoginClientFailedMessage"/> to the specified server.
        /// </summary>
        internal void SendLoginClientFailedMessage(int errorCode, byte[] sessionId, NetSocket socket, string reason = null, int remainingTime = -1)
        {
            LoginClientFailedMessage message = new LoginClientFailedMessage();

            message.SetErrorCode(errorCode);
            message.SetReason(reason);
            message.SetRemainingTime(remainingTime);
            NetMessageManager.SendMessage(socket, sessionId, message);
        }
Beispiel #2
0
        /// <summary>
        ///     Called when a <see cref="AskForAvatarProfileMessage"/> is received.
        /// </summary>
        internal void AskForAvatarProfileMessageReceived(AskForAvatarProfileMessage message)
        {
            LogicLong avatarId = message.RemoveAvatarId();
            LogicLong homeId   = message.RemoveHomeId();

            if (AvatarAccountManager.TryGet(avatarId, out AvatarAccount _))
            {
                AskForAvatarProfileFullEntryMessage askForAvatarProfileFullEntryMessage = new AskForAvatarProfileFullEntryMessage();
                askForAvatarProfileFullEntryMessage.SetAvatarId(avatarId);
                askForAvatarProfileFullEntryMessage.SetHomeId(homeId ?? avatarId);
                NetMessageManager.SendMessage(NetUtils.SERVICE_NODE_TYPE_ZONE_CONTAINER, NetManager.GetDocumentOwnerId(NetUtils.SERVICE_NODE_TYPE_ZONE_CONTAINER, avatarId), this._session.SessionId, askForAvatarProfileFullEntryMessage);
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Sends the specified <see cref="NetMessage"/> to the service.
        /// </summary>
        public void SendMessage(int serviceNodeType, NetMessage message)
        {
            NetSocket socket = this._serviceNodeSockets[serviceNodeType];

            if (socket != null)
            {
                NetMessageManager.SendMessage(socket, this.SessionId, message);
            }
            else
            {
                Logging.Warning("NetSession::sendMessage server is not set, nodeType: " + serviceNodeType);
            }
        }
Beispiel #4
0
        /// <summary>
        ///     Forwards the specified <see cref="PiranhaMessage"/> to the service.
        /// </summary>
        public void  SendPiranhaMessage(int serviceNodeType, PiranhaMessage message)
        {
            NetSocket socket = this._serviceNodeSockets[serviceNodeType];

            if (socket != null)
            {
                if (message.GetEncodingLength() == 0)
                {
                    message.Encode();
                }

                ForwardPiranhaMessage forwardPiranhaMessage = new ForwardPiranhaMessage();
                forwardPiranhaMessage.SetPiranhaMessage(message);
                NetMessageManager.SendMessage(socket, this.SessionId, forwardPiranhaMessage);
            }
        }
Beispiel #5
0
 /// <summary>
 ///     Sends the response <see cref="NetMessage"/> to the requester.
 /// </summary>
 internal static void SendResponseMessage(NetMessage requestMessage, NetMessage responseMessage)
 {
     NetMessageManager.SendMessage(requestMessage.GetServiceNodeType(), requestMessage.GetServiceNodeId(), requestMessage.GetSessionId(), responseMessage);
 }
Beispiel #6
0
 /// <summary>
 ///     Sets the <see cref="NetMessageManager" /> instance.
 /// </summary>
 internal void SetMessageManager(NetMessageManager manager)
 {
     this._messageManager = manager;
 }
Beispiel #7
0
        /// <summary>
        ///     Initializes this instance.
        /// </summary>
        public static void Initialize(int serviceNodeType, NetMessageManager messageManager, string[] args)
        {
            ServiceCore.ServiceNodeType     = serviceNodeType;
            ServiceCore.ServiceEnvironment  = "internal";
            ServiceCore.ConfigurationServer = "http://127.0.0.1/";
            ServiceCore.ServiceNodeId       = 0;

            if (args.Length > 0)
            {
                if (args.Length % 2 == 0)
                {
                    for (int i = 0; i < args.Length; i += 2)
                    {
                        string name  = args[i];
                        string value = args[i + 1];

                        switch (name)
                        {
                        case "-env":
                            if (!value.Equals("integration") &&
                                !value.StartsWith("integration-") &&
                                !value.Equals("stage") &&
                                !value.Equals("prod") &&
                                !value.Equals("internal") &&
                                !value.Equals("content-stage"))
                            {
                                Logging.Warning("ServiceCore::initialize unknown server environment: " + ServiceCore.ServiceEnvironment);
                            }

                            ServiceCore.ServiceEnvironment = value;
                            break;

                        case "-conf":
                            if (value.Length > 0)
                            {
                                if (value.StartsWith("http://") || value.StartsWith("https://"))
                                {
                                    if (!value.EndsWith("/"))
                                    {
                                        value += "/";
                                    }

                                    ServiceCore.ConfigurationServer = value;
                                }
                                else
                                {
                                    Logging.Warning("ServiceCore::initialize invalid server url: " + value);
                                }
                            }
                            else
                            {
                                Logging.Warning("ServiceCore::initialize server url is empty");
                            }

                            break;

                        case "-id":
                            ServiceCore.ServiceNodeId = int.Parse(value);
                            break;

                        default:
                            Logging.Warning("ServiceCore::initialize invalid args name");
                            break;
                        }
                    }
                }
                else
                {
                    Logging.Warning("ServiceCore::initialize invalid args length");
                }
            }

            WebManager.Initialize();

            ServiceCore.InitConfig();
            ServiceCore.InitLogic();
            ServiceCore.InitNet(messageManager);
        }
Beispiel #8
0
 /// <summary>
 ///     Initializes the net part.
 /// </summary>
 private static void InitNet(NetMessageManager messageManager)
 {
     NetManager.Initialize();
     NetMessaging.Initialize();
     NetMessaging.SetMessageManager(messageManager);
 }
Beispiel #9
0
 /// <summary>
 ///     Sets the <see cref="NetMessageManager" /> instance.
 /// </summary>
 public static void SetMessageManager(NetMessageManager manager)
 {
     NetMessaging._messageHandler.SetMessageManager(manager);
 }