Пример #1
0
        /// <summary>
        /// Loop do servidor.
        /// </summary>
        public static void Loop()
        {
            try {
                // Recebe os dados do login server
                LoginNetwork.ReceivedData();

                // Verifica e tenta uma nova conexão com o world server
                WorldNetwork.WorldServerConnect();

                // Recebe os dados do world server
                WorldNetwork.WorldServerReceiveData();

                // Verifica cada ip bloqueado, se o tempo expirou remove da lista
                GeoIp.CheckIpBlockedTime();

                if (Environment.TickCount >= tick + 1000)
                {
                    CPS   = count;
                    tick  = Environment.TickCount;
                    count = 0;
                }

                count++;
            }
            catch {
            }
        }
Пример #2
0
 public LoginServer(string[] args) : base(args)
 {
     name           = "Login Server";
     type           = ServerType.Authentication;
     port           = 13008;
     maxConnections = 200;
     network        = new LoginNetwork();
     base.RegisterDefaultSchedulers();
     // Scheduler.AddTask(new TestTask(Scheduler), 1, true);
 }
Пример #3
0
        /// <summary>
        /// Converts the account to sign in through another network.
        /// For instance, you might have created an anonymous account, that you later want to convert to an account
        /// logged on through a facebook account. Or, should you later want to convert this account to simply use an
        /// e-mail address, this is the method that you will want to call.
        /// In order to convert the account successfully, the provided network credentials need to be acceptable,
        /// just as when calling #CotcSdk.Cloud.Login.
        /// </summary>
        /// <returns>Promise resolved when the operation has completed.</returns>
        /// <param name="network">The target network to connect with later on.</param>
        /// <param name="networkId">The ID on the network. For example, with the facebook network, this would be the User ID.
        ///     On e-mail accounts e-mail then, this would be the e-mail address.</param>
        /// <param name="networkSecret">The secret for the network. For e-mail accounts, this would be the passord. For
        ///     facebook or other SNS accounts, this would be the user token.</param>
        public Promise<Done> Convert(LoginNetwork network, string networkId, string networkSecret)
        {
            Bundle config = Bundle.CreateObject();
            config["network"] = network.Describe();
            config["id"] = networkId;
            config["secret"] = networkSecret;

            HttpRequest req = Gamer.MakeHttpRequest("/v1/gamer/convert");
            req.BodyJson = config;
            return Common.RunInTask<Done>(req, (response, task) => {
                // Update the linked gamer instance with the additional parameters
                if (response.BodyJson.Has("gamer")) {
                    Gamer.Update(response.BodyJson["gamer"]);
                }
                task.PostResult(new Done(response.BodyJson));
            });
        }
Пример #4
0
        /// <summary>
        /// Fecha todas as conexões.
        /// </summary>
        public static void Close()
        {
            //Não permite nenhuma conexão (evitar possíveis erros)
            Settings.CantConnectNow = true;
            Settings.Server         = null;

            //Limpa as configurações
            Configuration.Clear();
            Authentication.Clear();
            LoginNetwork.Shutdown();
            WorldNetwork.Shutdown();
            CheckSum.Clear();

            //Fecha o arquivo de logs
            FileLog.CloseFileLog();
            Common_DB.Close();
        }
Пример #5
0
 /// <summary>Logs the current user in, using any supported social network.</summary>
 /// <returns>Promise resolved when the login has finished. The resulting Gamer object can then be used for many
 ///     purposes related to the signed in account.</returns>
 /// <param name="network">The network to connect with. If an user is recognized on a given network (same network ID),
 ///     then it will be signed back in and its user data will be used.</param>
 /// <param name="networkId">The ID on the network. For example, with the facebook network, this would be the User ID.
 ///     On e-mail accounts e-mail then, this would be the e-mail address.</param>
 /// <param name="networkSecret">The secret for the network. For e-mail accounts, this would be the passord. For
 ///     facebook or other SNS accounts, this would be the user token. For the LoginNetwork.GameCenter, the password
 ///     is not used, so you may pass "n/a".</param>
 /// <param name="preventRegistration">Fail instead of silently creating an account in case it doesn't already exist on
 ///     the CotC servers.</param>
 /// <param name="additionalOptions">Additional options can be passed, such as `thenBatch` to execute a batch after
 ///     login. Pass it as a Bundle with the additional keys. May not override `preventRegistration` key since it is
 ///     defined by the parameter of the same name.</param>
 public Promise<Gamer> Login(LoginNetwork network, string networkId, string networkSecret, bool preventRegistration = false, Bundle additionalOptions = null)
 {
     return Login(network.Describe(), networkId, networkSecret, preventRegistration, additionalOptions);
 }
Пример #6
0
 /// <summary>Checks that an user exists on a given network.</summary>
 /// <returns>Promise resolved when the user is found. If the user does not exist, it fails with
 ///     an HTTP status code of 400.</returns>
 /// <param name="network">Network used to log in (scoping the networkId).</param>
 /// <param name="networkId">The ID of the user on the network, like the e-mail address.</param>
 public Promise<Done> UserExists(LoginNetwork network, string networkId)
 {
     UrlBuilder url = new UrlBuilder("/v1/users")
         .Path(network.Describe()).Path(networkId);
     HttpRequest req = MakeUnauthenticatedHttpRequest(url);
     return Common.RunInTask<Done>(req, (response, task) => {
         task.PostResult(new Done(true, response.BodyJson));
     });
 }
Пример #7
0
        /// <summary>
        /// Inicializa o servidor
        /// </summary>
        public void InitializeServer()
        {
            trayIcon = new NotifyIcon();
            trayMenu = new ContextMenu();

            LuaScript.LuaConfig.InitializeConfig();

            Configuration.ParseConfigFile($"{Environment.CurrentDirectory}\\{Settings.FILE_CONFIG}");

            Settings.Discovery = Configuration.GetString("Discovery");
            WriteLog($"Discovery: {Settings.Discovery}", Color.Black);

            Settings.Port = Configuration.GetInt32("Port");
            WriteLog($"Port: {Settings.Port}", Color.Black);

            Settings.MaxConnection = Configuration.GetInt32("MaximumConnections");
            WriteLog($"MaxConnection: {Settings.MaxConnection}", Color.Black);

            Settings.ConnectionTimeOut = Configuration.GetInt32("ConnectionTimeOut");
            WriteLog($"ConnectionTimeOut: {Settings.ConnectionTimeOut}", Color.Black);

            Settings.LogSystem = Configuration.GetByte("LogSystem");
            WriteLog($"LogSystem: {Settings.LogSystem}", Color.Black);

            Settings.Sleep = Configuration.GetInt32("Sleep");
            WriteLog($"Sleep: {Settings.Sleep}", Color.Black);

            Settings.Version = Configuration.GetString("CheckVersion");
            WriteLog($"Version: {Settings.Version}", Color.BlueViolet);

            GeoIp.Enabled = Configuration.GetBoolean("GeoIp");
            var result = (GeoIp.Enabled == true) ? "Ativado" : "Desativado";

            WriteLog($"GeoIp: {result}", Color.BlueViolet);

            CheckSum.Enabled = Configuration.GetBoolean("CheckSum");
            result           = (CheckSum.Enabled == true) ? "Ativado" : "Desativado";
            WriteLog($"CheckSum: {result}", Color.BlueViolet);

            //1 - enabled
            result = (Settings.LogSystem == 1) ? "LogSystem: Ativado" : "LogSystem: Desativado";
            WriteLog("LogSystem: Desativado.", Color.Black);

            if (Settings.LogSystem == 1)
            {
                FileLog.OpenFileLog();
            }

            Authentication.Player = new HashSet <PlayerData>();

            InitializeServerConfig();
            InitializeDatabaseConfig();

            var tempError = string.Empty;

            if (!Common_DB.Open(out tempError))
            {
                WriteLog(tempError, Color.Red);
            }
            else
            {
                WriteLog("Connectado ao banco de dados", Color.Green);
            }

            WriteLog("Conectando World Server.", Color.Green);

            WorldNetwork.InitializeWorldServer();

            WriteLog("Login Server Start.", Color.Green);

            LoginNetwork.InitializeServer();

            GeoIp.ReadFile();

            #region Tray System
            trayMenu.MenuItems.Add("Mostrar", ShowForm);
            trayMenu.MenuItems.Add("Sair", quit_MenuItem_Click);

            trayIcon.Text = "Connect Server @";
            trayIcon.Icon = this.Icon;

            trayIcon.ContextMenu = trayMenu;
            #endregion
        }
Пример #8
0
        /// <summary>
        /// Links the account with another social network. Note that unlike Convert, this doesn't change the way the
        /// user would then sign in (the credentials remain the same).
        /// For instance, one may want to link their facebook account while keeping e-mail credentials in order to
        /// be able to share and play against gamers from their facebook social circle.
        /// In order to link the account successfully, the provided network credentials need to be acceptable,
        /// just as when calling #CotcSdk.Cloud.Login.
        /// </summary>
        /// <returns>Promise resolved when the operation has completed.</returns>
        /// <param name="network">The target network to link the account with.</param>
        /// <param name="networkId">The ID on the network. For example, with the facebook network, this would be the User ID.
        ///     On e-mail accounts e-mail then, this would be the e-mail address.</param>
        /// <param name="networkSecret">The secret for the network. For e-mail accounts, this would be the passord. For
        ///     facebook or other SNS accounts, this would be the user token.</param>
        public Promise<Done> Link(LoginNetwork network, string networkId, string networkSecret)
        {
            Bundle config = Bundle.CreateObject();
            config["network"] = network.Describe();
            config["id"] = networkId;
            config["secret"] = networkSecret;

            HttpRequest req = Gamer.MakeHttpRequest("/v1/gamer/link");
            req.BodyJson = config;
            return Common.RunInTask<Done>(req, (response, task) => {
                task.PostResult(new Done(response.BodyJson));
            });
        }
Пример #9
0
        /// <summary>
        /// When you have data about friends from another social network, you can post them to CotC servers using
        /// these function.
        /// This will automatically add them as a friend on CotC as they get recognized on our servers.
        /// The friends get associated to the domain of this object.
        /// Note: this function was once called PostSocialNetworkFriends but renamed due to it being misleading.
        /// </summary>
        /// <returns>Promise resolved when the operation has completed. The attached value is the same list as passed,
        ///     enriched with potential information about the gamer (member #CotcSdk.SocialNetworkFriend.ClanInfo) for
        ///     gamers who are already registered on CotC servers.</returns>
        /// <param name="network">The network with which these friends are associated.</param>
        /// <param name="friends">A list of data about the friends fetched on the social network.</param>
        /// <param name="automatching">If true, synchronizes the CotC friends with the list. That is, the provided
        /// social network friends become your friends on CotC as well (reported on ListFriends and such).</param>
        public Promise<SocialNetworkFriendResponse> ListNetworkFriends(LoginNetwork network, List<SocialNetworkFriend> friends, bool automatching = false)
        {
            var task = new Promise<SocialNetworkFriendResponse>();
            UrlBuilder url = new UrlBuilder("/v2.12/gamer/friends").Path(domain).QueryParam("network", network.Describe());
            HttpRequest req = Gamer.MakeHttpRequest(url);
            Bundle body = Bundle.CreateObject();
            Bundle friendData = (body["friends"] = Bundle.CreateObject());
            foreach (SocialNetworkFriend f in friends) {
                friendData[f.Id] = f.ToBundle();
            }
            body["automatching"] = automatching;

            req.BodyJson = body;
            return Common.RunRequest(req, task, (HttpResponse response) => {
                task.PostResult(new SocialNetworkFriendResponse(response.BodyJson));
            });
        }
Пример #10
0
 public LoginServer(string[] args) : base(args)
 {
     name    = "Login Server";
     port    = 13008;
     network = new LoginNetwork();
 }
Пример #11
0
 // Use this for initialization
 void Awake()
 {
     Instance = this;
     ml       = gameObject.AddComponent <MainThreadLoop>();
 }