Ejemplo n.º 1
0
        /// <summary>
        /// Called when the WebSocket connection used in a session has been established.
        /// </summary>
        protected override async void OnOpen()
        {
            string Provider = this.Context.QueryString.Get("provider");
            string Ticket   = this.Context.QueryString.Get("ticket");
            string Username = this.Context.QueryString.Get("id");
            string Password = this.Context.QueryString.Get("password");
            string PlayerId = this.Context.QueryString.Get("playerNetId");
            string Country  = this.Context.QueryString.Get("cc");
            string Version  = this.Context.QueryString.Get("clientGameVersion");

            var PubgSession = new PubgSession(this);

            if (this.Server.Sessions.TryAdd(PubgSession))
            {
                var Authenticated = await this.Authenticate(PubgSession, Provider, Ticket, Username, Password, PlayerId, Country, Version);

                if (Authenticated)
                {
                    ClientApi.ConnectionAccepted(PubgSession);
                }
                else
                {
                    Lobby.Log.Warning(this.GetType(), "Authenticated != true at OnOpen().");

                    PubgSession.Player = new Player
                    {
                        Username = Username,
                        Password = Password
                    };

                    await this.Server.Database.Create(PubgSession.Player);

                    ClientApi.ConnectionAccepted(PubgSession);
                }
            }
            else
            {
                Lobby.Log.Warning(this.GetType(), "At OnOpen(), TryAdd(PubgSession) == false, aborting.");
            }
        }