Exemplo n.º 1
0
        public async Task SendAsync_IGameCommand_IDiceConnectionSendAsyncPacket() 
        {
            var diceConnectionMock = new Mock<IDiceConnection>();
            diceConnectionMock.Setup(mock => mock.SendAsync(It.IsAny<IDicePacket>())).ReturnsAsync(123);
            diceConnectionMock.Setup(mock => mock.GetNextSequenceIdAsync()).ReturnsAsync(123u);
            var diceConnection = diceConnectionMock.Object;

            var isCalled = false;
            var instance = new GameConnection(diceConnection);
            await instance.SendAsync(new GameCommand() { Command = "listPlayers all" });

            diceConnectionMock.VerifyAll();
        }
	public void loginFromCanvas(string fbtoken)
    {
		if(loginHappened) return;
		loginHappened = true;
		Debug.Log("que que na unity: "+fbtoken);
		Save.Set(PlayerPrefsKeys.FACEBOOK_TOKEN.ToString(), fbtoken);
		
		GameConnection conn = new GameConnection(Flow.URL_BASE + "login/facebook/cvlogin.php", handleLoginFromCanvas);
		
		WWWForm form = new WWWForm();
		form.AddField("app_id", Info.appId);
		form.AddField("device", SystemInfo.deviceUniqueIdentifier.Replace("-", ""));
		form.AddField("fbtoken", fbtoken);
		
		conn.connect(form);
    }
Exemplo n.º 3
0
        public void Behaviour_DiceConnectionPacketReceived_GameDataReceivedIsInvoked()
        {
            var diceConnectionMock = new Mock<DiceConnection>();
            var diceConnection = diceConnectionMock.Object;

            var isCalled = false;
            var instance = new GameConnection(diceConnection);
            instance.GameDataReceived += (sender, e) =>
            {
                isCalled = true;
            };

            var dicePacket = new Mock<IDicePacket>().Object;
            diceConnectionMock.Raise(mock => mock.PacketReceived += null, new DicePacketEventArgs(dicePacket));

            Assert.True(isCalled);
        }
Exemplo n.º 4
0
        public async Task SendAsync_IGameCommand_EventGameDataSentIsInvoked()
        {
            var diceConnectionMock = new Mock<DiceConnection>();
            var diceConnection = diceConnectionMock.Object;
            diceConnectionMock.Setup(mock => mock.SendAsync(It.IsAny<IDicePacket>())).ReturnsAsync(123);

            var isCalled = false;
            var instance = new GameConnection(diceConnection);
            instance.GameDataSent +=
                (sender, e) =>
                {
                    isCalled = true;
                };

            var gameCommand = new GameCommand() { Command="myCommand"};
            await instance.SendAsync(gameCommand);

            Assert.True(isCalled);
        }
Exemplo n.º 5
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            PeerUI peer = new PeerUI();
            do
            {
                peer.ShowDialog();

                if (peer.peer.playStatus != 0)
                {
                    GameConnection gameConnection = null;
                    peer.peer.DisconnectFromServer();
                    if (peer.peer.playStatus == 2)
                    {
                        gameConnection = new GameConnection(peer.peer.PeerID);
                        gameConnection.PeerIDs = peer.peer.peerList;
                        System.Diagnostics.Debug.WriteLine("Crator Peer : " + peer.peer.IPTable[peer.peer.PeerID]);
                        List<string> ipAddress = new List<string>();
                        foreach (string ip in peer.peer.IPTable.Values)
                        {
                            ipAddress.Add(ip);
                        }
                        gameConnection.StartConfig(ipAddress);
                        gameConnection.WaitConfigComplete();
                    }
                    else if (peer.peer.playStatus == 1)
                    {
                        gameConnection = new GameConnection(peer.peer.PeerID);
                        System.Diagnostics.Debug.WriteLine("Peer : " + peer.peer.IPTable.Count);
                        gameConnection.WaitConfig();
                    }
                    using (Game1 game = new Game1(gameConnection))
                    {
                        game.IsCreator = (peer.peer.playStatus == 2);
                        game.Run();
                    }
                    gameConnection.Close();
                }
            } while (peer.peer.playStatus != 0);
        }
Exemplo n.º 6
0
        public GameClient(GameConnection connection, MapConnection mapConnection)
        {
            _mapClient = new MapClient(mapConnection);
            _mapClient.ConnectionOpened += MapClient_ConnectionOpened;
            _mapClient.ConnectionClosed += MapClient_ConnectionClosed;
            _mapClient.ConnectionFailed += MapClient_ConnectionFailed;
            _mapClient.MapLoaded += MapClient_MapLoaded;

            _connection = connection;
            _connection.PacketReceived += OnPacketReceived;
            _connection.Connected += OnConnectionOpened;
            _connection.Disconnected += OnConnectionClosed;

            Rand = new Random();
            I18n = new Language();
            Team = new List<Pokemon>();
            CurrentPCBox = new List<Pokemon>();
            Items = new List<InventoryItem>();
            Channels = new List<ChatChannel>();
            Conversations = new List<string>();
            Players = new Dictionary<string, PlayerInfos>();
            PCGreatestUid = -1;
            IsPrivateMessageOn = true;
        }
Exemplo n.º 7
0
 public static void InternalDisconnect(GameConnection connection)
 {
     connection.ActiveCharacter.IsInternalDisconnect = true;
     connection.Close();
 }
Exemplo n.º 8
0
 public LeaveWorldTask(GameConnection connection, byte target)
 {
     _connection = connection;
     _target     = target;
 }
        // получаем пакеты от клиента
        public void OnReceive(GameConnection connection, byte[] buf, int bytes)
        {
            int offset;

            try
            {
                var stream = new PacketStream();
                if (connection.LastPacket != null)
                {
                    stream.Insert(0, connection.LastPacket);
                    connection.LastPacket = null;
                }
                offset = stream.Count; // запомним начало пакета
                stream.Insert(stream.Count, buf);
                while (stream != null && stream.Count > 0)
                {
                    ushort len;
                    try
                    {
                        len = stream.ReadUInt16();
                    }
                    catch (MarshalException)
                    {
                        //_log.Warn("Error on reading type {0}", type);
                        stream.Rollback();
                        connection.LastPacket = stream;
                        stream = null;
                        continue;
                    }
                    var packetLen = len + stream.Pos;
                    if (packetLen <= stream.Count)
                    {
                        stream.Rollback();
                        var stream2 = new PacketStream();
                        stream2.Replace(stream, 0, packetLen);
                        if (stream.Count > packetLen)
                        {
                            var stream3 = new PacketStream();
                            stream3.Replace(stream, packetLen, stream.Count - packetLen);
                            stream = stream3;
                        }
                        else
                        {
                            stream = null;
                        }

                        stream2.ReadUInt16(); //len
                        stream2.ReadByte();   //unk
                        var  level   = stream2.ReadByte();
                        uint type    = 0;
                        byte crc     = 0;
                        byte counter = 0;
                        if (level == 1)
                        {
                            crc     = stream2.ReadByte(); // TODO 1.2 crc
                            counter = stream2.ReadByte(); // TODO 1.2 counter
                        }
                        if (level == 5)
                        {
                            //пакет от клиента, дешифруем
                            //------------------------------
                            var input = new byte[stream2.Count - 2];
                            Buffer.BlockCopy(stream2, 2, input, 0, stream2.Count - 2);
                            var output = DecryptCs.Decode(input, GameConnection.CryptRsa.XorKey, GameConnection.CryptRsa.AesKey, GameConnection.CryptRsa.Iv, m_numPck);
                            m_numPck++;                                                  //увеличим номер пакета от клиента
                            var OutBytes = new byte[output.Length + 5];
                            Buffer.BlockCopy(stream2, offset, OutBytes, 0, 5);           // скопируем (ushort)len, 0005
                            Buffer.BlockCopy(output, 1, OutBytes, 5, output.Length - 1); // сформируем полный расшифрованные пакет
                            // заменим шифрованные данные на дешифрованные
                            var strm = new PacketStream();
                            strm.Write(OutBytes);
                            stream2.Replace(strm, 0, OutBytes.Length);
                            stream2.ReadUInt16();
                            //------------------------------
                        }
                        type = stream2.ReadUInt16();

                        _packets[level].TryGetValue(type, out var classType);
                        if (classType == null)
                        {
                            HandleUnknownPacket(connection, type, level, stream2);
                        }
                        else
                        {
                            var packet = (GamePacket)Activator.CreateInstance(classType);
                            packet.Level      = level;
                            packet.Connection = connection;
                            packet.Decode(stream2);
                        }
                    }
                    else
                    {
                        stream.Rollback();
                        connection.LastPacket = stream;
                        stream = null;
                    }
                }
            }
            catch (Exception e)
            {
                connection?.Shutdown();
                _log.Error(e);
            }
        }
Exemplo n.º 10
0
        public static void serverCmdCycleWeapon(GameConnection client, string direction)
        {
            ShapeBase obj = client["player"];

            obj.cycleWeapon(direction);
        }
        public void Create(GameConnection connection, string name, byte race, byte gender, uint[] body,
                           UnitCustomModelParams customModel, byte ability1)
        {
            var nameValidationCode = NameManager.Instance.ValidationCharacterName(name);

            if (nameValidationCode == 0)
            {
                var characterId = CharacterIdManager.Instance.GetNextId();
                NameManager.Instance.AddCharacterName(characterId, name);
                var template = GetTemplate(race, gender);

                var character = new Character(customModel);
                character.Id                     = characterId;
                character.AccountId              = connection.AccountId;
                character.Name                   = name.Substring(0, 1).ToUpper() + name.Substring(1);
                character.Race                   = (Race)race;
                character.Gender                 = (Gender)gender;
                character.Position               = template.Position.Clone();
                character.Position.ZoneId        = template.ZoneId;
                character.Level                  = 1;
                character.Faction                = FactionManager.Instance.GetFaction(template.FactionId);
                character.FactionName            = "";
                character.LaborPower             = 50;
                character.LaborPowerModified     = DateTime.UtcNow;
                character.NumInventorySlots      = template.NumInventorySlot;
                character.NumBankSlots           = template.NumBankSlot;
                character.Inventory              = new Inventory(character);
                character.Updated                = DateTime.UtcNow;
                character.Ability1               = (AbilityType)ability1;
                character.Ability2               = AbilityType.None;
                character.Ability3               = AbilityType.None;
                character.ReturnDictrictId       = template.ReturnDictrictId;
                character.ResurrectionDictrictId = template.ResurrectionDictrictId;
                character.Slots                  = new ActionSlot[85];
                for (var i = 0; i < character.Slots.Length; i++)
                {
                    character.Slots[i] = new ActionSlot();
                }

                var items = _abilityItems[ability1];
                SetEquipItemTemplate(character.Inventory, items.Items.Headgear, EquipmentItemSlot.Head, items.Items.HeadgearGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Necklace, EquipmentItemSlot.Neck, items.Items.NecklaceGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Shirt, EquipmentItemSlot.Chest, items.Items.ShirtGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Belt, EquipmentItemSlot.Waist, items.Items.BeltGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Pants, EquipmentItemSlot.Legs, items.Items.PantsGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Gloves, EquipmentItemSlot.Hands, items.Items.GlovesGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Shoes, EquipmentItemSlot.Feet, items.Items.ShoesGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Bracelet, EquipmentItemSlot.Arms, items.Items.BraceletGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Back, EquipmentItemSlot.Back, items.Items.BackGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Undershirts, EquipmentItemSlot.Undershirt, items.Items.UndershirtsGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Underpants, EquipmentItemSlot.Underpants, items.Items.UnderpantsGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Mainhand, EquipmentItemSlot.Mainhand, items.Items.MainhandGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Offhand, EquipmentItemSlot.Offhand, items.Items.OffhandGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Ranged, EquipmentItemSlot.Ranged, items.Items.RangedGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Musical, EquipmentItemSlot.Musical, items.Items.MusicalGrade);
                SetEquipItemTemplate(character.Inventory, items.Items.Cosplay, EquipmentItemSlot.Cosplay, items.Items.CosplayGrade);
                for (var i = 0; i < 7; i++)
                {
                    if (body[i] == 0 && template.Items[i] > 0)
                    {
                        body[i] = template.Items[i];
                    }
                    SetEquipItemTemplate(character.Inventory, body[i], (EquipmentItemSlot)(i + 19), 0);
                }

                byte slot = 10;
                foreach (var item in items.Supplies)
                {
                    var createdItem = ItemManager.Instance.Create(item.Id, item.Amount, item.Grade);
                    character.Inventory.AddItem(createdItem);

                    character.SetAction(slot, ActionSlotType.Item, item.Id);
                    slot++;
                }

                items = _abilityItems[0];
                if (items != null)
                {
                    foreach (var item in items.Supplies)
                    {
                        var createdItem = ItemManager.Instance.Create(item.Id, item.Amount, item.Grade);
                        character.Inventory.AddItem(createdItem);

                        character.SetAction(slot, ActionSlotType.Item, item.Id);
                        slot++;
                    }
                }

                character.Abilities = new CharacterAbilities(character);
                character.Abilities.SetAbility(character.Ability1, 0);

                character.Actability = new CharacterActability(character);
                foreach (var(id, actabilityTemplate) in _actabilities)
                {
                    character.Actability.Actabilities.Add(id, new Actability(actabilityTemplate));
                }

                character.Skills = new CharacterSkills(character);
                foreach (var skill in SkillManager.Instance.GetDefaultSkills())
                {
                    if (!skill.AddToSlot)
                    {
                        continue;
                    }
                    character.SetAction(skill.Slot, ActionSlotType.Skill, skill.Template.Id);
                }

                slot = 1;
                while (character.Slots[slot].Type != ActionSlotType.None)
                {
                    slot++;
                }
                foreach (var skill in SkillManager.Instance.GetStartAbilitySkills(character.Ability1))
                {
                    character.Skills.AddSkill(skill, 1, false);
                    character.SetAction(slot, ActionSlotType.Skill, skill.Id);
                    slot++;
                }

                character.Appellations = new CharacterAppellations(character);
                character.Quests       = new CharacterQuests(character);
                character.Mails        = new CharacterMails(character);
                character.Portals      = new CharacterPortals(character);
                character.Friends      = new CharacterFriends(character);

                character.Hp = character.MaxHp;
                character.Mp = character.MaxMp;

                if (character.Save())
                {
                    connection.Characters.Add(character.Id, character);
                    connection.SendPacket(new SCCreateCharacterResponsePacket(character));
                }
                else
                {
                    connection.SendPacket(new SCCharacterCreationFailedPacket(3));
                    CharacterIdManager.Instance.ReleaseId(characterId);
                    NameManager.Instance.RemoveCharacterName(characterId);
                    // TODO release items...
                }
            }
            else
            {
                connection.SendPacket(new SCCharacterCreationFailedPacket(nameValidationCode));
            }
        }
Exemplo n.º 12
0
 //Put all your overrides here.
 public override string onConnectRequest(GameConnection client, string netAddress, string name)
 {
     console.print("###Connection Request: " + netAddress + "###");
     return(base.onConnectRequest(client, netAddress, name));
 }
Exemplo n.º 13
0
 public void OnDisabled()
 {
     GameConnection.DestroyInstance <Engine>(e => e.Shutdown());
     GameConnection.DestroyInstance <MainWindow>();
 }
Exemplo n.º 14
0
        public override void ProcessPacket()
        {
            GameConnection gc = (GameConnection)Connection;

            GameService.Instance.StartGame(gc.Player);
        }
 public X2EnterWorldResponsePacket(short reason, bool gm, uint token, ushort port, GameConnection connection) :
     base(SCOffsets.X2EnterWorldResponsePacket, 5)
 {
     _connection = connection;
     _reason     = reason;
     _token      = token;
     _port       = port;
     _gm         = gm;
 }
Exemplo n.º 16
0
 protected override void writeImpl(GameConnection con)
 {
     writeD(_accountId);
     writeQ(_time);
 }
Exemplo n.º 17
0
 public static void ClearBottomPrint(GameConnection client)
 {
     t3d.console.commandToClient(client, "clearBottomPrint");
 }
Exemplo n.º 18
0
 public static void ClearCenterPrint(GameConnection client)
 {
     t3d.console.commandToClient(client, "ClearCenterPrint");
 }
Exemplo n.º 19
0
        public void Disconnect(GameConnection connection)
        {
            clients.Remove(connection.Client);

            if (clients.Count == 0 && gameTimer != null)
                gameTimer.Dispose();

            if (Started)
                ProcessCommand(new RemovePlayerCommand(connection.Player));
            else
                game.Players.Remove(connection.Player);
        }
Exemplo n.º 20
0
 public Topology(GameConnection connection)
 {
     _connection = connection;
 }
Exemplo n.º 21
0
 protected override void writeImpl(GameConnection con)
 {
     writeD(_reqId);
     writeD(_result);
     writeQ(_points);
 }
Exemplo n.º 22
0
 static public void GameConnectionspamReset(GameConnection thisobj)
 {
     thisobj["isSpamming"] = false.AsString();
 }
Exemplo n.º 23
0
 public void TryLogin()
 {
     GameConnection.SendData(new LoginPacketOut().AddLogin(this));
 }
Exemplo n.º 24
0
 public static void serverCmdUnmountWeapon(GameConnection client)
 {
     ((Player)client["player"]).unmountImage(omni.iGlobal["$WeaponSlot"]);
 }
Exemplo n.º 25
0
 public static void serverCmdMissionStartPhase2CacheAck(GameConnection client)
 {
     _missionLoadBase.serverCmdMissionStartPhase2CacheAck(client);
 }
Exemplo n.º 26
0
            public ClientHandler(GameConnection tc, Socket handler)
            {
                this.handler = handler;
                Connection = tc;

                PeerID = (handler.RemoteEndPoint as IPEndPoint).Address.ToString();
                string[] split_res = PeerID.Split('.');
                PeerID = "P" + split_res[split_res.Length - 1];
            }
Exemplo n.º 27
0
 public static void serverCmdMissionStartPhase2Ack(GameConnection client, string seq, PlayerData playerDB)
 {
     _missionLoadBase.serverCmdMissionStartPhase2Ack(client, seq, playerDB);
 }
Exemplo n.º 28
0
 protected override void writeImpl(GameConnection con)
 {
     writeD(_responseId);
     writeD(_keyCount);
     writeD(_rewardId);
 }
Exemplo n.º 29
0
 public static void serverCmdMissionStartPhase3Ack(GameConnection client, string seq)
 {
     _missionLoadBase.serverCmdMissionStartPhase3Ack(client, seq);
 }
Exemplo n.º 30
0
        public override void onImageUnmount(ShapeBase obj, int slot, float dt)
        {
            GameConnection client = obj["client"];

            client.refreshWeaponHud(0, string.Empty, string.Empty, string.Empty, 0);
        }
Exemplo n.º 31
0
 public static void sendMsgClientKilled_Impact(string msgtype, GameConnection client, GameConnection sourceclient, string damloc)
 {
     if (client.isObject())
     {
         message.MessageAll(msgtype, "%1 fell to his death!", client["playerName"]);
     }
     // console.GetVarString(string.Format("{0}.playerName", client)));
 }
Exemplo n.º 32
0
 public GameController(GameConnection connection)
 {
     _connection = connection;
 }
Exemplo n.º 33
0
 public ScreenCollection(GameConnection connection)
 {
     _connection = connection;
 }
Exemplo n.º 34
0
 public static void sendMsgClientKilled_Suicide(string msgtype, GameConnection client, GameConnection sourceclient, string damloc)
 {
     if (client.isObject())
     {
         message.MessageAll(msgtype, "%1 takes his own life!", client["playerName"]);
     }
 }
Exemplo n.º 35
0
 protected override void writeImpl(GameConnection con)
 {
     writeD(_client.PlayerId);
     writeC(_client.ToKen.Length);
     writeB(_client.ToKen);
 }
Exemplo n.º 36
0
 public void Ctor_IDiceConnectionMock_DiceConnectionIDiceConnectionMock()
 {
     var diceConnection = new Mock<IDiceConnection>().Object;
     var instance = new GameConnection(diceConnection);
     Assert.Equal(diceConnection, instance.DiceConnection);
 }
Exemplo n.º 37
0
        public static void sendMsgClientKilled_Default(string msgtype, GameConnection client, GameConnection sourceclient, string damloc)
        {
            if (!client.isObject())
            {
                return;
            }
            if (sourceclient == client)
            {
                sendMsgClientKilled_Suicide(msgtype, client, sourceclient, damloc);
            }

            else if (omni.console.GetVarString(sourceclient["team"]) != string.Empty && sourceclient["team"] != client["team"])
            {
                message.MessageAll(msgtype, "%1 killed by %2 - friendly fire!", client["playerName"], sourceclient["playerName"]);
            }
            else
            {
                message.MessageAll(msgtype, "%1 gets nailed by %2!", client["playerName"], sourceclient.isObject() ? sourceclient["playerName"] : "a Bot!");
            }
        }
Exemplo n.º 38
0
        public override void onInventory(ShapeBase user, int value)
        {
            //Player can be either a player object or a aiturret...

            GameConnection client = user["client"];

            for (int i = 0; i < 8; i++)
            {
                if (user.GetType() == typeof(Player))
                {
                    ShapeBaseImageData image = (user).getMountedImage(i);
                    if (image <= 0)
                    {
                        continue;
                    }

                    if (!image["ammo"].isObject())
                    {
                        continue;
                    }
                    if (((SimObject)image["ammo"]).getId() != this.getId())
                    {
                        continue;
                    }


                    (user).setImageAmmo(i, value != 0);
                }
                else if (user.GetType() == typeof(AITurretShape))
                {
                    ShapeBaseImageData image = (user).getMountedImage(i);
                    if (image <= 0)
                    {
                        continue;
                    }

                    if (!image["ammo"].isObject())
                    {
                        continue;
                    }
                    if (((SimObject)image["ammo"]).getId() != getId())
                    {
                        continue;
                    }


                    (user).setImageAmmo(i, value != 0);
                }


                int currentammo = user.getInventory(this); // ShapeBaseShapeBaseGetInventory(player, thisobj);

                if (user.getClassName() != "Player")
                {
                    continue;
                }

                int amountInClips;

                if (this["clip"].isObject())
                {
                    amountInClips = user.getInventory(this["clip"]);
                    // ShapeBaseShapeBaseGetInventory(player, thisobj["clip"]);

                    amountInClips *= this["maxInventory"].AsInt();

                    amountInClips += user["remaining" + getName()].AsInt();
                }
                else
                {
                    amountInClips = currentammo;
                    currentammo   = 1;
                }
                if (user["client"] != string.Empty && !user["isAiControlled"].AsBool())
                {
                    client.setAmmoAmountHud(currentammo, amountInClips);
                }
            }
        }
Exemplo n.º 39
0
 public AccountPayment(GameConnection connection)
 {
     _connection = connection;
 }
Exemplo n.º 40
0
	// Obtem a lista de ads com o servidor
	protected static void getAdList()
	{	
		if (!AdvertisementManager.isEnabled())
			return;
		
		GameConnection conn = new GameConnection(Flow.URL_BASE + "login/ads.php", AdvertisementManager.manager.handleGetAdList);
		
		WWWForm form = new WWWForm();
		form.AddField("app", Info.appId);

#if UNITY_ANDROID
		form.AddField("os", "android");
#elif UNITY_IPHONE
		form.AddField("os", "ios");
#else 
		form.AddField("os", "web");
#endif
		
		AdvertisementManager.manager.StartCoroutine(conn.startConnection(form));
	}
Exemplo n.º 41
0
 public virtual void serverCmdMissionStartPhase2CacheAck(GameConnection client)
 {
     client["currentPhase"] = "1.5";
 }
Exemplo n.º 42
0
	// GLA
	// Loga o usuario no servidor
	private void logUserIn()
	{
		//Debug.Log("email: "+email);
		//Debug.Log("password: "******"error, inform email");
			if (email.IsEmpty()) Flow.game_native.showMessage("Error", "Please inform an e-mail.");
			
			return;
		}
		
		// Up Top Fix Me
		Flow.game_native.startLoading();
		
		//GameConnection conn = new GameConnection(components.url_login, connectionResult);
		GameConnection conn = new GameConnection(Flow.URL_BASE + "login/", connectionResult);
			
		WWWForm form = new WWWForm();
		form.AddField("app_id", Info.appId);
		form.AddField("email", email);
		form.AddField("password", password);
		form.AddField("device", SystemInfo.deviceUniqueIdentifier.Replace("-",""));
		
		string device_push = PushNotifications.getPushDevice();
		if (device_push != null) form.AddField("device_push", device_push);
		// Info.GetAppType() = Free, Pay, Custom1, Custom2, Custom3
		form.AddField("app_version", Info.version.ToString());
		form.AddField("app_type", Info.appType.ToString());
		
#if UNITY_EDITOR
		form.AddField("app_platform","UnityEditor");
#elif UNITY_IPHONE
		form.AddField("app_platform","iOS");
#elif UNITY_ANDROID
		form.AddField("app_platform","Android");	
#elif UNITY_WEBPLAYER
		form.AddField("app_platform","Facebook");	
#endif
		
		conn.connect(form);
		//Debug.Log("conecta novamente");
	}
Exemplo n.º 43
0
        public void OnReceive(GameConnection connection, byte[] buf, int bytes)
        {
            try
            {
                var stream = new PacketStream();
                if (connection.LastPacket != null)
                {
                    stream.Insert(0, connection.LastPacket);
                    connection.LastPacket = null;
                }
                stream.Insert(stream.Count, buf);
                while (stream != null && stream.Count > 0)
                {
                    ushort len;
                    try
                    {
                        len = stream.ReadUInt16();
                    }
                    catch (MarshalException)
                    {
                        //_log.Warn("Error on reading type {0}", type);
                        stream.Rollback();
                        connection.LastPacket = stream;
                        stream = null;
                        continue;
                    }
                    var packetLen = len + stream.Pos;
                    if (packetLen <= stream.Count)
                    {
                        stream.Rollback();
                        var stream2 = new PacketStream();
                        stream2.Replace(stream, 0, packetLen);
                        if (stream.Count > packetLen)
                        {
                            var stream3 = new PacketStream();
                            stream3.Replace(stream, packetLen, stream.Count - packetLen);
                            stream = stream3;
                        }
                        else
                        {
                            stream = null;
                        }
                        stream2.ReadUInt16(); //len
                        stream2.ReadByte();   //unk
                        var level = stream2.ReadByte();

                        byte crc     = 0;
                        byte counter = 0;
                        if (level == 1)
                        {
                            crc     = stream2.ReadByte(); // TODO 1.2 crc
                            counter = stream2.ReadByte(); // TODO 1.2 counter
                        }

                        var type = stream2.ReadUInt16();
                        _packets[level].TryGetValue(type, out var classType);
                        if (classType == null)
                        {
                            HandleUnknownPacket(connection, type, level, stream2);
                        }
                        else
                        {
                            var packet = (GamePacket)Activator.CreateInstance(classType);
                            packet.Level      = level;
                            packet.Connection = connection;
                            packet.Decode(stream2);
                        }
                    }
                    else
                    {
                        stream.Rollback();
                        connection.LastPacket = stream;
                        stream = null;
                    }
                }
            }
            catch (Exception e)
            {
                connection?.Shutdown();
                _log.Error(e);
            }
        }