Пример #1
0
        public override void processMessage(RawMessage message)
        {
            string senderUsername = message.getUTF8String("s");
            string msg            = message.getUTF8String("m");

            Runner.Graphics.displayGameChatMessage(senderUsername, msg);
        }
Пример #2
0
 public override void processMessage(RawMessage message, User user)
 {
     if (user.userState == User.UserState.LOBBY || user.userState == User.UserState.QUEUE)
     {
         OutgoingMessages.Lobby.LChatMessage.sendMessage(user.username, message.getUTF8String("cmd"));
     }
 }
Пример #3
0
        public override void processMessage(MessageArrivedEventArgs messageArgs)
        {
            User user;

            // zaten login olmus biri tekrar login olmaya calismasin sakin
            if (Game.clientUserMap.TryGetValue(messageArgs.sender, out user) == false)
            {
                RawMessage message = messageArgs.message;

                if (message != null && message.containsField("username"))
                {
                    string username = message.getUTF8String("username");

                    if (username.StartsWith("ArenaSize:"))
                    {
                        int size = int.Parse(username.Split(':')[1]);
                        Game.queue.maxUserCount = Math.Max(2, size);

                        OM_LoginResult.SendMessage(messageArgs.sender, false);
                    }
                    else
                    {
                        user = new User(messageArgs.sender, username);
                        Game.clientUserMap.Add(messageArgs.sender, user);

                        OM_LoginResult.SendMessage(messageArgs.sender, true, user);
                    }
                }
            }
        }
Пример #4
0
 public override void processMessage(RawMessage message, User user)
 {
     if (user.userState == User.UserState.LOBBY || user.userState == User.UserState.QUEUE)
     {
         OutgoingMessages.Lobby.LChatMessage.sendMessage(user.username, message.getUTF8String("cmd"));
     }
 }
    public void btn_LoginClick()
    {
        RawMessage message = new RawMessage();

        message.putUTF8String("username", input_username.text);
        message.putUTF8String("password", input_password.text);

        Assets.Scripts.Engine.Network.sslStream.WriteSingleMessage(message);
        RawMessage msg = Assets.Scripts.Engine.Network.sslStream.ReadSingleMessage();

        if (msg == null)
        {
            Assets.Scripts.Engine.Network.server.Disconnect();
            output_loginResult.text = "Connection is Lost.";
            return;
        }

        if (msg.getBool("response"))
        {
            //Assets.Scripts.Engine.Network.sslStream.Close();  // DUE TO A BUG -kardeslerim- WE CANNOT CLOSE THE STREAM.
            // Cunku close yaparsak, nereden geldigi belirsiz 37 byte, serverda bu client'a ait messageListenera dusuyor.
            // sadece unity'de oluyor, .net'te duzgun calisiyor. Muhtemelen Mono kaynakli bir sorun.

            Assets.Scripts.Engine.Network.server.ListenForMessages();
            output_loginResult.color = Color.green;
        }

        output_loginResult.text = msg.getUTF8String("reason");
        input_username.text     = "";
        input_password.text     = "";
        input_username.selected = true;
        StartCoroutine(hideLoginResult());
    }
Пример #6
0
 public override void processMessage(RawMessage message, User user)
 {
     if (user.userState == User.UserState.GAME)
     {
         OutgoingMessages.Game.GChatMessage.sendMessage(user, message.getUTF8String("cmd"));
     }
 }
Пример #7
0
 public override void processMessage(RawMessage message, User user)
 {
     if (user.userState == User.UserState.GAME )
     {
         OutgoingMessages.Game.GChatMessage.sendMessage(user, message.getUTF8String("cmd"));
     }
 }
Пример #8
0
        public override void processMessage(RawMessage message)
        {
            bool result = message.getBool("r");

            if (result)
            {                
                UserMe.initializeUserMe(message.getInt("ui"),
                                        message.getUTF8String("un"),
                                        message.getInt("psp"),
                                        message.getInt("csp"),
                                        message.getInt("bsp"),
                                        message.getBoolArray("usn"));
            }
            else
                ;//TODO login fail. handle it
            
        }
Пример #9
0
        public override void processMessage(RawMessage message)
        {
            bool result = message.getBool("r");

            if (result)
            {
                UserMe.initializeUserMe(message.getInt("ui"),
                                        message.getUTF8String("un"),
                                        message.getInt("psp"),
                                        message.getInt("csp"),
                                        message.getInt("bsp"),
                                        message.getBoolArray("usn"));
            }
            else
            {
                ;//TODO login fail. handle it
            }
        }
Пример #10
0
        private void loginProcess()
        {
            string username;
            string password;

            string          certPassword = "******";
            X509Certificate certificate  = new X509Certificate2("ScienceWars_SSL_certificate.pfx", certPassword);

            SslStreamObject sslStream = session.client.createSslStreamObject(true);

            try
            {
                sslStream.AuthenticateAsServer(certificate);
            }
            catch (Exception e)
            {
                return;
            }

            while (true)
            {
                RawMessage message = sslStream.ReadSingleMessage();

                if (message == null)
                {
                    return;
                }

                username = message.getUTF8String("username"); // TODO exception check
                password = message.getUTF8String("password");

                int userId = 0;
                if (dal.credentialCheck(username, password, out userId)) //username, password, out userId))
                {
                    Database.Models.UserDataModel userData = new Database.Models.UserDataModel();

                    if (dal.getUserData(userId, TypeIdGenerator.getScienceNodeCount(), out userData))
                    {
                        //TODO unlocked Science Nodes bize dbId olarak geliyor ancak biz o id yi sanki isimden uretilen typeId si gibi kullaniyoruz. burada bir convert yapmak lazim
                        // aldigin unlockedScienceNodes arrayindeki her bir indexi dbId olarak tutan scienceNode u bul, o nodun typeId sini al, o typeId yi index olarak kullanarak yeni bir bool[] doldur.
                        // yeni olusturdugun bool array i User konstraktirina gonder.

                        sendLoginResponse(sslStream, true, "successful");
                        //sslStream.Close();        // DUE TO A BUG -kardeslerim- WE CANNOT CLOSE THE STREAM.
                        // Cunku close yaparsak, nereden geldigi belirsiz 37 byte, client'a ait messageListenera dusuyor.
                        // sadece unity'de oluyor, .net'te duzgun calisiyor. Muhtemelen Mono kaynakli bir sorun.

                        session.client.ListenForMessages();
                        User user = new User(session, username, userData.physPoints, userData.chemPoints, userData.chemPoints, userData.unlockedScienceNodes);
                        runner.userLoggedIn(user);
                        return;
                    }
                    else
                    {
                        sendLoginResponse(sslStream, false, "cannot retrieve user data");
                    }
                }
                else
                {
                    sendLoginResponse(sslStream, false, "wrong username or password");
                }
            }
        }
Пример #11
0
		public override void processMessage(RawMessage message)
		{
			string senderUsername = message.getUTF8String("s");
			string msg = message.getUTF8String("m");
			Runner.Graphics.displayGameChatMessage(senderUsername,msg);
		}