void OnAuth(NetworkMessage netMsg)
    {
        ServerAuth serverAuth = netMsg.ReadMessage <ServerAuth>();

        Debug.Log("User Authenticated! " + serverAuth.username + ":" + netMsg.conn.connectionId);


        //TODO:randomize
        Vector3 position = selectedMap.getRandomSpawnPoint();
        //TODO:randomize
        Welcome welcome = new Welcome();

        welcome.id       = netMsg.conn.connectionId;
        welcome.users    = ConnectedUsers.ToArray();
        welcome.position = position;
        NetworkServer.SendToClient(netMsg.conn.connectionId, 778, welcome);
        User u = new User();

        u.id        = netMsg.conn.connectionId;
        u.username  = serverAuth.username;
        u.media     = serverAuth.media;
        u.position  = position;
        u.rotation  = Quaternion.identity;
        u.direction = Vector3.zero;
        u.kills     = 0;
        ConnectedUsers.Add(u);

        sendToAllExcept(netMsg.conn.connectionId, 811, u);

        /*foreach(User current in ConnectedUsers.FindAll(x => x.id != netMsg.conn.connectionId)){
         *              NetworkServer.SendToClient(current.id,811,u);
         *      }*/
    }
Exemple #2
0
        //private static void Check



        private static void GetNextObject()
        {
            var newUser = new AccountData()
            {
                SteamAccountId = "Babster", aType = AccountData.ActionType.CheckPwd
            };

            newUser.Name           = "Babster";
            newUser.AdditionalData = "temp pwd";

            using (var client = ServerAuth.CreateClient())
            {
                client.BaseAddress = new Uri(ServerAuth.ServerAddress + "/api/Story/NextStep");

                string      tStr     = JsonConvert.SerializeObject(newUser);
                HttpContent tContent = new StringContent(tStr, null, "application/json");

                var response = client.GetAsync(client.BaseAddress);
                response.Wait();
                var          result    = response.Result;
                var          resString = result.Content.ReadAsStringAsync().Result;
                StringAndInt nextStep  = JsonConvert.DeserializeObject <StringAndInt>(resString);
                Console.WriteLine("Next step type: {0}, id: {1}", nextStep.StrValue, nextStep.IntValue);
            }
        }
 static void Main(string[] args)
 {
     LogManager.Init();
     LogManager.GetLoggerClass().Infos("Voulez vous voir les datas en Hexa ? [y/n]");
     do
     {
         var key = Console.ReadLine();
         if (key == "y")
         {
             Hexa = true;
             break;
         }
         else if (key == "n")
         {
             break;
         }
         else
         {
             LogManager.GetLoggerClass().Infos("Commande incorrect merci de choisir entre 'y' ou 'n' !");
         }
     } while (true);
     LogManager.GetLoggerClass().Infos("Lancement du MITM !");
     ServerLogin = new ServerAuth(5558);
     ServerGame  = new ServerGame(5556);
     Console.Read();
 }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //ServerAuth.Auth();
        ServerAuth sa = new ServerAuth();

        sa.recMessage();
    }
Exemple #5
0
 private static void GetUserStats()
 {
     using (var client = ServerAuth.CreateClient())
     {
         var          response = client.GetAsync(ServerAuth.ServerAddress + "/api/Admiral/GetStats").Result;
         AdmiralStats tStats   = JsonConvert.DeserializeObject <AdmiralStats>(response.Content.ReadAsStringAsync().Result);
         Console.WriteLine("Stat points left: {0}", tStats.StatPointsLeft);
         foreach (PlayerStat stat in tStats.Stats)
         {
             Console.WriteLine("{0} : {1}", stat.Name, stat.Value);
         }
     }
 }
Exemple #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ServerAuth sa       = new ServerAuth();
        var        touurl   = "http://wx.qlogo.cn/mmopen/icE1QGMQwDGFjFdfUk8X1Ueiczt2xPgcQyCPUnj2TJdbCib672lrLJqNdQ9cJec73giasN7v4bodia7CgDyJ9UwarEHONyqLJus66/0";
        string     pathtou  = saveimage(touurl);
        string     erma     = sa.GetQrcode("74");
        string     pathMs   = Server.MapPath("../upload_Img/maseter.jpg");
        string     picName  = Guid.NewGuid().ToString() + ".png";
        string     strPath  = HttpContext.Current.Request.FilePath + "/../../upload_Img/Pic"; //项目根路径
        string     SavePath = Server.MapPath(strPath + "/" + picName);                        //保存文件的路径
        string     text     = "我是谁";

        CombinImage(pathMs, saveQrcode(erma), pathtou, text).Save(SavePath);
    }
Exemple #7
0
    void Start()
    {
        Cursor.visible              = !Cursor.visible;
        Cursor.lockState            = CursorLockMode.Locked;
        QualitySettings.vSyncCount  = 0; // VSync must be disabled
        Application.targetFrameRate = 30;
        players      = new Dictionary <int, GameObject>();
        hpTxt        = GameObject.Find("hp").GetComponent <Text>();
        dmTxt        = GameObject.Find("dm").GetComponent <Text>();
        youTxt       = GameObject.Find("youTxt").GetComponent <Text>();
        maxTxt       = GameObject.Find("maxTxt").GetComponent <Text>();
        timeTxt      = GameObject.Find("timeTxt").GetComponent <Text>();
        recordTxt    = GameObject.Find("recordTxt").GetComponent <Text>();
        hpFill       = GameObject.Find("hpfill").GetComponent <Image>();
        keyMenu      = GameObject.Find("menuchiavi").GetComponent <KeyMenu>();
        quitmenu     = GameObject.Find("quitmenu").transform;
        UI           = GameObject.Find("UI");
        respawnTimer = GameObject.Find("esito").GetComponent <RespawnTimer>();
        materieShow  = GameObject.Find("materieshow").GetComponent <MaterieShow>();
        cam          = GameObject.Find("Camera").GetComponent <CameraController>();
        overlayItems = new List <OverlayControl>((OverlayControl[])GameObject.FindObjectsOfType(typeof(OverlayControl)));
        nm           = GameObject.Find("NetworkManager").GetComponent <NetworkManager>();
        maxTxt.text  = nm.getConfiguration().kills.ToString();

        if (nm.getConfiguration().time2newmatch > 0)
        {
            timeLeft = 0;
            respawnTimer.Start(nm.getConfiguration().time2newmatch, "Partita terminata!");
        }
        else
        {
            timeLeft = nm.getConfiguration().timeLeft;
        }

        calculateProperties();

        nm.nc.RegisterHandler(100, MatchEnded);
        nm.nc.RegisterHandler(101, MatchStarted);
        nm.nc.RegisterHandler(778, OnWelcome);
        nm.nc.RegisterHandler(811, OnEnemyConnect);

        ServerAuth serverAuth = new ServerAuth();

        serverAuth.username = username;
        serverAuth.media    = baseDamage;
        Debug.Log("Connected: " + nm.nc.isConnected);
        nm.nc.Send(777, serverAuth);
        regenerateMaterie();
    }
Exemple #8
0
        private static void RegisterUserChanges()
        {
            using (var client = ServerAuth.CreateClient())
            {
                AdmiralStats sampleStats = new AdmiralStats(true);

                var postTask = client.PostAsJsonAsync <AdmiralStats>(ServerAuth.ServerAddress + "/api/Admiral", sampleStats);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    Console.WriteLine("stat change registered");
                }
                else
                {
                    Console.WriteLine(result.Content.ReadAsStringAsync().Result);
                }
            }
        }
        public async Task <AuthSession> SignInAsync(string username, string password)
        {
            var sentObj = new ServerAuth
            {
                Email    = username,
                Password = password,
                Action   = "SignIn"
            };

            Debug.WriteLine($"api is:{Settings.Shared.API_AWS_AuthSignin}");

            string res = await Settings.Shared.API_AWS_AuthSignin
                         .WithTimeout(20)
                         .PostJsonAsync(sentObj)
                         .ReceiveString();

            Debug.WriteLine($"AWS_Service> Response from server:{res}");

            return(JsonConvert.DeserializeObject <AuthSession>(res));
        }
Exemple #10
0
        private static void GetSceneInner()
        {
            using (var client = ServerAuth.CreateClient())
            {
                client.BaseAddress = new Uri(ServerAuth.ServerAddress + "/api/Story/");

                var postTask = client.GetAsync("scene?SceneId=1");
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var            resString = result.Content.ReadAsStringAsync().Result;
                    RebelScene     sceneData = JsonConvert.DeserializeObject <RebelScene>(resString);
                    RebelSceneFull RF        = new RebelSceneFull(ref sceneData);
                    Console.WriteLine("Loaded scene {0}", RF.ToString());
                }
                else
                {
                    Console.WriteLine(result.StatusCode);
                }
            }
        }
        public async Task <AuthSession> SignInAsync(string username, string password)
        {
            var sentObj = new ServerAuth
            {
                Email    = username,
                Password = password,
                Action   = "SignIn"
            };



            string res = await Constants.API_SERVER
                         .WithTimeout(20)
                         .PostJsonAsync(sentObj)
                         .ReceiveString();


            Debug.WriteLine($"Response from server:{res}");

            return(JsonConvert.DeserializeObject <AuthSession>(res));

            //Debug.WriteLine($"Is there error:{resultObject.error}");
            //Debug.WriteLine($"Is there message:{resultObject.message}");
        }
Exemple #12
0
 private static void GetToken()
 {
     Console.WriteLine(ServerAuth.GetToken());
 }