/// <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); }
/// <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); } }
/// <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); } }
/// <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); } }
/// <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); }
/// <summary> /// Sets the <see cref="NetMessageManager" /> instance. /// </summary> internal void SetMessageManager(NetMessageManager manager) { this._messageManager = manager; }
/// <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); }
/// <summary> /// Initializes the net part. /// </summary> private static void InitNet(NetMessageManager messageManager) { NetManager.Initialize(); NetMessaging.Initialize(); NetMessaging.SetMessageManager(messageManager); }
/// <summary> /// Sets the <see cref="NetMessageManager" /> instance. /// </summary> public static void SetMessageManager(NetMessageManager manager) { NetMessaging._messageHandler.SetMessageManager(manager); }