Example #1
0
        public static bool InitWidthLogin()
        {
            try
            {
                var reqCookies = new CookieContainer();

                CookieContainer resCookies = null;

                reqCookies = new CookieContainer();
                reqCookies.Add(new Cookie("MM_WX_NOTIFY_STATE", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("MM_WX_SOUND_STATE", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("last_wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("login_frequency", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("mm_lang", "zh_CN", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("pgv_pvi", LoginHelper.pgv_pvi, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("pgv_si", LoginHelper.pgv_si, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwx_auth_ticket", LoginHelper.LoginPageCookie.webwx_auth_ticket, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwx_data_ticket", LoginHelper.LoginPageCookie.webwx_data_ticket, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwxuvid", LoginHelper.LoginPageCookie.webwxuvid, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxloadtime", CalcTimeUtil.GetUnixDateTime(new TimeSpan(365, 0, 0, 0)), "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxsid", LoginHelper.LoginPageCookie.wxsid, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));

                var weixinInitUrl = string.Format(weixinInitUrlTemple, LoginHelper.LoginPageXml.pass_ticket, new object().GetHashCode());

                var data = new Dictionary <string, string>();

                var postData = "{\"BaseRequest\":{\"Uin\":\"" + LoginHelper.LoginPageCookie.wxuin + "\",\"Sid\":\"" + LoginHelper.LoginPageCookie.wxsid + "\",\"Skey\":\"" + LoginHelper.LoginPageXml.skey + "\",\"DeviceID\":\"e478901587692997\"}}";

                data.Add(WebClientUtil.JsonDataPrex, postData);

                string json = WebClientUtil.GetResponseOnCookie(weixinInitUrl, "post", reqCookies, out resCookies, data, "application/json;charset=UTF-8");

                InitHelper.WebWeixinInit = SerializeUtil.Deserialize <WebWeixinInit>(json);

                if (InitHelper.WebWeixinInit == null || WebWeixinInit.BaseResponse.Ret != 0)
                {
                    return(false);
                }
                return(true);
            }
            catch
            {
            }
            return(false);
        }
Example #2
0
        public void DeserializeItems(string items)
        {
            var list = SerializeUtil.Deserialize <List <SerializedItem> >(items);

            foreach (var item in list)
            {
                if (item.Equipped == 0)
                {
                    SortInventoryItemSlotsOnLoad(item);
                }
                else
                {
                    EquipItemOnRestore(item.ItemId);
                }
            }
            _usedInventorySlots = list.Count;
        }
    /// <summary>
    /// 获取场景中的其他玩家信息的应答
    /// </summary>
    /// <param name="model"></param>
    private void OnSceneChar(SocketModel model)
    {
        if (model.message == null)
        {
            return;
        }
        RespSceneCharacters resp = SerializeUtil.Deserialize <RespSceneCharacters>(model.message);

        for (int i = 0; i < resp.characters.Count; i++)
        {
            CharacterDTO dto = resp.characters[i];
            RoleCfg      cfg = ConfigManager.instance.GetRoleCfg(dto.cfgid);
            Vector3      pos = new Vector3(dto.pos_x, dto.pos_y, dto.pos_z);
            //CharacterManager.instance.Create(dto.id, cfg, pos, typeof(OtherPlayer));
            Battle.instance.Create <Player>(dto);
        }
    }
Example #4
0
        protected override bool OnHandleMessage(IMessage message, PhotonServerPeer serverPeer)
        {
            if (!message.Parameters.ContainsKey((byte)ClientParameterCode.Object))
            {
                DebugUtils.Logp(DebugUtils.Level.ERROR, CLASSNAME, "OnHandleMessage", "No StatAllocationData object passed. Exiting handler.");
                return(true);
            }

            var para = new Dictionary <byte, object>
            {
                { (byte)ClientParameterCode.PeerId, message.Parameters[(byte)ClientParameterCode.PeerId] },
                { (byte)ClientParameterCode.SubOperationCode, message.Parameters[(byte)ClientParameterCode.SubOperationCode] }
            };

            var instance = Util.GetCPlayerInstance(Server, message);

            var statAllocData = SerializeUtil.Deserialize <StatAllocationData>(message.Parameters[(byte)ClientParameterCode.Object]);

            if (statAllocData.ResetPoints)
            {
                resetAllAllocatedStatPoints(instance);
            }
            else
            {
                foreach (var stat in statAllocData.Allocations)
                {
                    ((StatHolder)instance.Stats).SetStatByID(stat.Key, stat.Value);
                    instance.GetCharData <GeneralStats>().TotalAllocatedStats += stat.Value;
                    instance.Stats.AddToStat <StatPoints>(-stat.Value);
                }
            }

            var debugMessage = statAllocData.ResetPoints ? "Stats successfully reset!" : "Stats successfully added!";

            para.Add((byte)ClientParameterCode.Object, SerializeUtil.Serialize(instance.Stats.GetMainStatsForEnemy()));
            para.Add((byte)ClientParameterCode.StatsToAllocate, instance.Stats.GetStat <StatPoints>());

            serverPeer.SendOperationResponse(new OperationResponse(message.Code)
            {
                ReturnCode   = (int)ErrorCode.OK,
                DebugMessage = debugMessage,
                Parameters   = para
            }, new SendParameters());
            return(true);
        }
Example #5
0
    private void OnReqMove(UserToken token, SocketModel model)
    {
        ReqMove req = SerializeUtil.Deserialize <ReqMove>(model.message);

        //保存坦克的实时坐标
        AccountData acc = CacheManager.instance.GetAccount(token.accountid);

        if (acc == null)
        {
            return;
        }

        Battle battle = CacheManager.instance.GetBattle(acc.battleid, acc.battleType);

        if (battle == null)
        {
            return;
        }

        Tank t = battle.GetTank(token.accountid);

        if (t != null && t.hp > 0)
        {
            ////校验两帧的移动距离
            //float deltaTime = Time.time * 0.001f - t.lastMoveTime;
            //float distance = deltaTime * 5;

            //float reqDistance = Luna3D.Vector3.Distance(Tools.ToLunaVec3(req.pos), t.lastPos);
            //if (reqDistance > distance + 0.2f) return;

            //t.lastMoveTime = Time.time * 0.001f;

            //修改缓存
            t.pos = new Vector3(req.pos.x, 0, req.pos.z);
            t.rot = Tools.ToLunaVec3(req.rot);

            t.lastPos = t.pos;
            //给别人发通知
            NotifyMove notify = new NotifyMove();
            notify.id  = token.accountid;
            notify.pos = Tools.ToVec_3(t.pos);
            notify.rot = req.rot;
            MsgSender.SendOther <NotifyMove>(battle.accounts, token, (int)MsgID.NotifyMove, notify);
        }
    }
    // 创建角色应答
    private void OnCreateCharacter(SocketModel model)
    {
        RespAddCharacter resp = SerializeUtil.Deserialize <RespAddCharacter>(model.message);

        if (resp.msgtips == (uint)MsgTips.NameRepeat)
        {
            MessageBox.Show("角色重名");
        }
        else
        {
            // 缓存当前角色
            DataCache.instance.currentCharacter = resp.character;
            DataCache.instance.AddChracter(resp.character);

            WindowManager.instance.Close <CreateRoleWnd>();
            SelectRole.instance.ShowSelectRole();
        }
    }
Example #7
0
 static RegionConstants()
 {
     Values = new Dictionary <ConstantType, Dictionary <byte, int> >();
     using (var session = NHibernateHelper.OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             var regionConstants = session.QueryOver <SubServerCommon.Data.NHibernate.Constants>().SingleOrDefault();
             var stats           = SerializeUtil.Deserialize <Dictionary <byte, int> >(regionConstants.statsJson);
             var currency        = SerializeUtil.Deserialize <Dictionary <byte, int> >(regionConstants.currencyJson);
             var experience      = SerializeUtil.Deserialize <Dictionary <byte, int> >(regionConstants.experienceLevelJson);
             Values.Add(ConstantType.STAT_POINTS_PER_LEVEL, stats);
             Values.Add(ConstantType.CURRENCY_PER_LEVEL, currency);
             Values.Add(ConstantType.EXPERIENCE_FOR_LEVEL, experience);
             transaction.Commit();
         }
     }
 }
Example #8
0
        public static void SendMsg(string fromUserName, string toUserName, string content)
        {
            var msg = new SendMessage(LoginHelper.LoginPageCookie.wxuin,
                                      LoginHelper.LoginPageCookie.wxsid,
                                      LoginHelper.LoginPageXml.skey,
                                      1,
                                      fromUserName,
                                      toUserName,
                                      content, "e526874475065566", MessageHelper.SendMessageResult.LocalID, MessageHelper.SendMessageResult.LocalID);

            var json = SerializeUtil.Serialize(msg);

            var reqCookies = new CookieContainer();

            reqCookies.Add(new Cookie("pgv_pvi", LoginHelper.pgv_pvi, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("pgv_si", LoginHelper.pgv_si, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("refreshTimes", "2", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("MM_WX_NOTIFY_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("MM_WX_SOUND_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("mm_lang", "zh_CN", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwxuvid", LoginHelper.LoginPageCookie.webwxuvid, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_auth_ticket", LoginHelper.LoginPageCookie.webwx_auth_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("login_frequency", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("last_wxuin", "LoginHelper.LoginPageCookie.wxuin", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxloadtime", "1495855277_expired", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxsid", LoginHelper.LoginPageCookie.wxsid, "/", "wx.qq.com"));

            CookieContainer resCookies = null;

            var SendMsg = string.Format(SendMsgTemple, LoginHelper.LoginPageXml.pass_ticket);

            if (LoginHelper.WX2)
            {
                SendMsg = SendMsg.Replace("//wx.", "//wx2.");
            }

            var dic = new Dictionary <string, string>();

            dic.Add(WebClientUtil.JsonDataPrex, json);

            MessageHelper.SendMessageResult = SerializeUtil.Deserialize <SendMessageResult>(WebClientUtil.GetResponseOnCookie(SendMsg, "post", reqCookies, out resCookies, dic, "application/json;charset=UTF-8"));
        }
Example #9
0
        private ItemStatHolder FillStats(ItemStatHolder statHolder, ItemDBEntry dbItem)
        {
            var statsDict = SerializeUtil.Deserialize <Dictionary <string, float> >(dbItem.Stats);

            var statsCopy = new Dictionary <Type, IStat>(statHolder.Stats);

            foreach (var stat in statsCopy)
            {
                if (statsDict != null && statsDict.ContainsKey(stat.Value.Name) && statsDict[stat.Value.Name] > 0)
                {
                    ((IItemStatHolder)statHolder).SetStat(stat.Value, statsDict[stat.Value.Name]);
                }
                else
                {
                    statHolder.Stats.Remove(stat.Key);
                }
            }
            return(statHolder);
        }
Example #10
0
 /// <summary>
 /// Receives the message.
 /// </summary>
 /// <param name="message"></param>
 private void OnReceiveMessage(string name, string message)
 {
     if (_receiveMessageCallback == null || string.IsNullOrWhiteSpace(message))
     {
         return;
     }
     try
     {
         var clientParameter = SerializeUtil.Deserialize <TParameter>(message);
         if (clientParameter == null)
         {
             throw new ArgumentNullException($"'VersionHub' Receiving server push version information deserialization failed , receive content :  { message } .");
         }
         _receiveMessageCallback.Invoke(clientParameter);
     }
     catch (Exception ex)
     {
         throw new Exception($"'VersionHub' Receive message error :  { ex.Message }", ex.InnerException);
     }
 }
Example #11
0
    private void OnBuyGoodsRsp(SocketModel model)
    {
        RspBuyGoods rsp = SerializeUtil.Deserialize <RspBuyGoods>(model.message);

        if (rsp.msgtips == (uint)MsgTips.BuyGoodsSuccess)
        {
            WindowManager.instance.Close <BuyTypeWnd>();
            DataCache.instance.currentCharacter.gold    = (int)rsp.gold;
            DataCache.instance.currentCharacter.diamond = (int)rsp.diamond;
            WindowManager.instance.Get <MallWnd>().UpdateGoldDiamond((int)rsp.gold, (int)rsp.diamond);
        }
        else if (rsp.msgtips == (uint)MsgTips.DiamondNotEnough)
        {
            MessageBox.Show("钻石不足");
        }
        else if (rsp.msgtips == (uint)MsgTips.GoldNotEnough)
        {
            MessageBox.Show("金币不足");
        }
    }
Example #12
0
        /** Receives forwarded message from client with chat input object,
         *  parses the message (verifies character fields) and sends the textmessage out to each client connected to chat server
         *
         *  Will be parsed differently based on type of the chat message (General, Whisper, Guild, etc..)
         */

        protected override bool OnHandleMessage(IMessage message, PhotonServerPeer serverPeer)
        {
            if (message.Parameters.ContainsKey((byte)ClientParameterCode.Object))
            {
                Guid peerId   = new Guid((Byte[])message.Parameters[(byte)ClientParameterCode.PeerId]);
                var  chatItem = SerializeUtil.Deserialize <ChatItem>(message.Parameters[(byte)ClientParameterCode.Object]);

                switch (chatItem.Type)
                {
                case (ChatType.General):
                    chatItem.ByPlayer = Server.ConnectionCollection <SubServerConnectionCollection>().Clients[peerId].ClientData <ChatPlayer>().CharacterName;
                    //chatItem.Text - contains client's input string;

                    foreach (var client in Server.ConnectionCollection <SubServerConnectionCollection>().Clients)
                    {
                        var para = new Dictionary <byte, object>()
                        {
                            { (byte)ClientParameterCode.PeerId, client.Key.ToByteArray() },
                            { (byte)ClientParameterCode.Object, SerializeUtil.Serialize(chatItem) }
                        };
                        var eventData = new EventData {
                            Code = (byte)ClientEventCode.Chat, Parameters = para
                        };

                        client.Value.ClientData <ServerData>().ServerPeer.SendEvent(eventData, new SendParameters());
                    }
                    break;

                case (ChatType.Whisper):
                    break;

                case (ChatType.Guild):
                    break;

                default:
                    break;
                }
            }
            return(true);
        }
Example #13
0
    private void OnLogin(UserToken token, SocketModel model)
    {
        ReqLogin req = SerializeUtil.Deserialize <ReqLogin>(model.message);

        RespLogin resp = new RespLogin();

        string             sql      = string.Format("select * from account where account = '{0}'", req.account);
        List <AccountData> accDatas = MysqlManager.instance.ExecQuery <AccountData>(sql);

        if (accDatas.Count <= 0)         // 没有这个账号
        {
            resp.msgtips = (uint)MsgTips.NoAccount;
        }
        else                            // 有这个账号
        {
            AccountData acc = accDatas[0];

            if (CacheManager.instance.IsAccountOnline(acc.id))     // 账号已经在线,就不让再登录了
            {
                resp.msgtips = (uint)MsgTips.AccountHasOnline;
            }
            else
            {
                if (acc.password == req.password)
                {
                    resp.msgtips = (uint)MsgTips.LoginSuccess;

                    CacheManager.instance.AccountOnline(acc.id, acc.account, acc.password);

                    token.accountid = acc.id;
                }
                else
                {
                    resp.msgtips = (uint)MsgTips.PasswordError;
                }
            }
        }

        NetworkManager.Send(token, (int)MsgID.ACC_LOGIN_SRES, resp);
    }
    // 角色移动请求
    public void OnReqCharacterMove(UserToken token, SocketModel model)
    {
        ReqCharacterMove req = SerializeUtil.Deserialize <ReqCharacterMove>(model.message);

        BattleData battleData = CacheManager.instance.GetBattleData(token.characterid);
        Battle     b          = GetCurrentBattle(battleData.battleType, battleData.battleid);
        Player     p          = b.GetCharacter(token.characterid) as Player;

        p.Move(new Luna3D.Vector3(req.dest.x, req.dest.y, req.dest.z));


        NotifyCharacterMove notify = new NotifyCharacterMove();

        notify.characterid = (uint)token.characterid;
        notify.position    = req.dest;
        Dictionary <int, Player> chs = b.GetTypeChar <Player>(common.CharacterType.Player);

        foreach (Player ch in chs.Values)
        {
            NetworkManager.Send(ch.token, (int)MsgID.NotifyCharacterMove, notify);
        }
    }
Example #15
0
        protected override bool OnHandleMessage(IMessage message, PhotonServerPeer serverPeer)
        {
            _instance     = Util.GetCPlayerInstance(Server, message);
            _currentFight = _instance.CurrentFight;

            var newMove = SerializeUtil.Deserialize <FightMove>(message.Parameters[(byte)ClientParameterCode.Object]);

            newMove.PeerObjectId   = _instance.ObjectId;
            newMove.TargetObjectId = _instance.Target.ObjectId;

            _currentFight.AddMoveSendPkg(_instance, newMove);

//			var para = new Dictionary<byte, object>()
//			{
//				{(byte)ClientParameterCode.PeerId, message.Parameters[(byte)ClientParameterCode.PeerId]},
//				{(byte)ClientParameterCode.SubOperationCode, MessageSubCode.SwitchTarget},
//				{(byte)ClientParameterCode.ObjectId, _instance.TargetId}
//			};
//			serverPeer.SendOperationResponse(new OperationResponse(message.Code) {Parameters = para}, new SendParameters());
//			Server.Log.DebugFormat("Sending SwitchTarget response for {0} targetting ({1}){2}", _instance.Name, _instance.TargetId, _instance.Target.Name);
            return(true);
        }
Example #16
0
    private void OnNotifyReborn(SocketModel model)
    {
        NotifyReborn notify = SerializeUtil.Deserialize <NotifyReborn>(model.message);

        BaseTank t = TankManager.instance.GetTank(notify.tank.id);

        if (t != null)
        {
            TankManager.instance.RemoveTank(t);
            t.Clear();
        }
        BaseTank tank = null;

        if (notify.tank.id == CacheManager.instance.account)
        {
            tank = new Tank(notify.tank);
        }
        else
        {
            tank = new OtherTank(notify.tank);
        }
        TankManager.instance.AddTank(tank);
    }
            public void ResponseContainerWithDecryptedResponse()
            {
                //Arrange
                var xmlResponse = XmlResource.Response.GetPerson();
                var bodyElement = xmlResponse.SelectSingleNode("/env:Envelope/env:Body", NamespaceManager.InitalizeNamespaceManager(xmlResponse));
                var expectedDeserializedResponse = SerializeUtil.Deserialize <HentPersonerRespons>(bodyElement.InnerXml);
                //Act
                var candidate = new ResponseContainer(GenerateStreamFromString(xmlResponse.OuterXml));

                //Assert
                var cmp = new Comparator();

                cmp.AreEqual(expectedDeserializedResponse, SerializeUtil.Deserialize <HentPersonerRespons>(candidate.BodyElement.InnerXml));
                Assert.NotNull(candidate.HeaderBinarySecurityToken);
                Assert.NotNull(candidate.BodyElement);
                Assert.NotNull(candidate.Cipher);
                Assert.NotNull(candidate.HeaderSecurityElement);
                Assert.NotNull(candidate.HeaderSignature);
                Assert.NotNull(candidate.HeaderSignatureElement);
                Assert.NotNull(candidate.TimestampElement);

                Assert.Null(candidate.EncryptedBody);
            }
Example #18
0
        private void method_1()
        {
            SortedDictionary <string, string> dictionary = null;

            dictionary = SerializeUtil.Deserialize(true, this.string_0) as SortedDictionary <string, string>;
            if (dictionary != null)
            {
                for (int i = 0; i < this.customStyleDataGrid1.Rows.Count; i++)
                {
                    string key = this.customStyleDataGrid1.Rows[i].Cells["ColName"].Value.ToString();
                    if (dictionary.ContainsKey(key))
                    {
                        string[] strArray = dictionary[key].Split(new char[] { ',' });
                        for (int j = 0; j < (this.customStyleDataGrid1.Columns.Count - 1); j++)
                        {
                            ((DataGridViewDisableCheckBoxCell)this.customStyleDataGrid1[j, i]).Enabled = true;
                            ((DataGridViewDisableCheckBoxCell)this.customStyleDataGrid1[j, i]).Value   = Convert.ToInt32(strArray[j]);
                        }
                    }
                }
                this.customStyleDataGrid1.Invalidate();
                base.Invalidate();
            }
        }
Example #19
0
    // 卸载物品
    private void OnInvUnloadEquip(UserToken token, SocketModel model)
    {
        ReqUnloadItem req = SerializeUtil.Deserialize <ReqUnloadItem>(model.message);

        // 查找第一个空的栏位
        int firstEmptySlot = CacheManager.instance.GetFirstEmptySlot(token.characterid);

        EquipData equipData = CacheManager.instance.GetEquipData(token.characterid, req.slot);

        // 获取背包栏位物品数据
        InventoryData invData = CacheManager.instance.GetInvData(token.characterid, firstEmptySlot);

        int itemid = invData.itemid;

        invData.itemid   = equipData.itemid;
        equipData.itemid = itemid;

        RespUnloadItem resp = new RespUnloadItem();

        resp.equip = EquipData.GetInvDTO(equipData);
        resp.inv   = InventoryData.GetInvDTO(invData);

        NetworkManager.Send(token, (int)MsgID.INV_Unload_SRES, resp);
    }
Example #20
0
        private static void SendImage(string fromUserName, string toUserName, string mediaId)
        {
            var reqCookies = new CookieContainer();

            reqCookies.Add(new Cookie("pgv_pvi", LoginHelper.pgv_pvi, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("pgv_si", LoginHelper.pgv_si, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("refreshTimes", "2", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("MM_WX_NOTIFY_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("MM_WX_SOUND_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("mm_lang", "zh_CN", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwxuvid", LoginHelper.LoginPageCookie.webwxuvid, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_auth_ticket", LoginHelper.LoginPageCookie.webwx_auth_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_data_ticket", LoginHelper.LoginPageCookie.webwx_data_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("login_frequency", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("last_wxuin", "LoginHelper.LoginPageCookie.wxuin", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxloadtime", "1495855277_expired", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxsid", LoginHelper.LoginPageCookie.wxsid, "/", "wx.qq.com"));

            CookieContainer resCookies = null;

            var SendImpageUrl = string.Format(SendImpageUrlTemple, LoginHelper.LoginPageXml.pass_ticket);

            if (LoginHelper.WX2)
            {
                SendImpageUrl = SendImpageUrl.Replace("//wx.", "//wx2.");
            }

            var json = "{\"BaseRequest\":{\"Uin\":" + LoginHelper.LoginPageCookie.wxuin + ",\"Sid\":\"" + LoginHelper.LoginPageCookie.wxsid + "\",\"Skey\":\"" + LoginHelper.LoginPageXml.skey + "\",\"DeviceID\":\"e856174200109311\"},\"Msg\":{\"Type\":3,\"MediaId\":\"" + mediaId + "\",\"Content\":\"\",\"FromUserName\":\"" + fromUserName + "\",\"ToUserName\":\"" + toUserName + "\",\"LocalID\":\"14963106567540883\",\"ClientMsgId\":\"14963106567540883\"},\"Scene\":0}";

            var dic = new Dictionary <string, string>();

            dic.Add(WebClientUtil.JsonDataPrex, json);

            MessageHelper.SendMessageResult = SerializeUtil.Deserialize <SendMessageResult>(WebClientUtil.GetResponseOnCookie(SendImpageUrl, "post", reqCookies, out resCookies, dic, "application/json;charset=UTF-8"));
        }
Example #21
0
    // 角色离线
    private void OnCharacterOffline(UserToken token, SocketModel model)
    {
        ReqCharacterOffline req = SerializeUtil.Deserialize <ReqCharacterOffline>(model.message);

        RespCharacterOffline resp = new RespCharacterOffline();

        // 移除缓存
        if (CacheManager.instance.IsCharOnline(token.characterid))
        {
            CacheManager.instance.CharOffline(token.characterid);
            resp.msgtips = (uint)MsgTips.CharOfflineSuccess;
        }

        // 离开世界
        //if(Scene.instance.players.ContainsKey(token.characterid))
        //{
        //    Scene.instance.LeaveWorld(token.characterid);
        //}

        CacheManager.instance.RemoveBattleData(token.characterid);

        // 给当前玩家发离线应答
        NetworkManager.Send(token, (int)MsgID.CHAR_OFFLINE_SRES, resp);
    }
Example #22
0
    private void OnReqEnterRoom(UserToken token, SocketModel model)
    {
        ReqEnterRoom req = SerializeUtil.Deserialize <ReqEnterRoom>(model.message);
        AccountData  acc = CacheManager.instance.GetAccount(token.accountid);

        if (acc.roomid != 0)
        {
            return;
        }

        Room r = CacheManager.instance.GetWaitRoom((EBattle)req.battleType, req.limitNumber);

        r.AddAccount(acc);

        RspEnterRoom rsp = new RspEnterRoom();

        rsp.roomid = r.roomid;
        NetworkManager.Send <RspEnterRoom>(token, (int)MsgID.RspEnterRoom, rsp);

        //房间满
        if (r.accounts.Count >= r.limtNum)
        {
            Battle b = null;
            if (req.battleType == (int)EBattle.Arena)
            {
                b = CacheManager.instance.CreateArena(r.limtNum, r.accounts);
            }
            else
            {
                b = CacheManager.instance.CreateSurvival(r.limtNum, r.accounts);
            }

            //清空roomid
            for (int i = 0; i < r.accounts.Count; i++)
            {
                r.accounts[i].roomid = 0;
            }

            //通知战斗开始
            NotifyBattleStart notify = new NotifyBattleStart();
            notify.battleid    = b.battleid;
            notify.battleType  = req.battleType;
            notify.numberLimit = req.limitNumber;

            List <Tank> tanks = b.GetALLTanks();

            for (int i = 0; i < tanks.Count; i++)
            {
                Tank    t1  = tanks[i];
                TankDTO dto = new TankDTO();
                dto.id       = t1.uid;
                dto.hp       = t1.hp;
                dto.nickName = t1.nickName;
                dto.pos      = Tools.ToVec_3(t1.pos);
                dto.color    = Tools.UC2TC(t1.color);
                dto.team     = (int)t1.team;
                notify.tanks.Add(dto);
            }
            MsgSender.SendAll <NotifyBattleStart>(r.accounts, (int)MsgID.NotifyBattleStart, notify);
            CacheManager.instance.RemoveRoom(r.roomid);
        }
    }
Example #23
0
    private void OnTipError(SocketModel model)
    {
        TipsError rsp = SerializeUtil.Deserialize <TipsError>(model.message);

        Debug.LogError(rsp.code);
    }
Example #24
0
    private void OnReqHit(UserToken token, SocketModel model)
    {
        ReqHit req = SerializeUtil.Deserialize <ReqHit>(model.message);

        if (req.bulletPos == null)
        {
            return;
        }

        Random r   = new Random();
        var    atk = r.Next(10, 20);

        AccountData acc   = CacheManager.instance.GetAccount(token.accountid);
        AccountData enemy = CacheManager.instance.GetAccount(req.enemy);

        if (acc.battleType == EBattle.Arena && acc.team == enemy.team)
        {
            return;
        }

        Battle battle = CacheManager.instance.GetBattle(acc.battleid, acc.battleType);

        if (battle == null)
        {
            return;
        }

        Tank t        = battle.GetTank(req.enemy);
        Tank attacker = battle.GetTank(acc.account);

        if (t != null && t.hp > 0 && attacker != null && attacker.hp > 0)
        {
            Console.WriteLine(Vector3.Distance(Tools.ToLunaVec3(req.bulletPos), t.pos));
            //校验子弹和敌人的坐标
            if (Vector3.Distance(Tools.ToLunaVec3(req.bulletPos), t.pos) > 2.5f)
            {
                return;
            }
            // Console.WriteLine(Time.time * 0.001f - attacker.lastHitTime);
            ////校验两次命中时间
            // if (Time.time * 0.001f - attacker.lastHitTime < 0.7f) return;

            attacker.lastHitTime = Time.time * 0.001f;

            t.hp -= atk;
            //伤害统计
            acc.hurt += atk;

            NotifyHit notify = new NotifyHit();
            notify.id = req.enemy;

            notify.damage = atk;

            MsgSender.SendAll <NotifyHit>(battle.accounts, (int)MsgID.NotifyHit, notify);
            //死亡
            if (t.hp <= 0)
            {
                t.hp = 0;
                acc.killCount++;
                enemy.deathCount++;

                //通知所有人有个坦克死了
                NotifyDeath not = new NotifyDeath();
                not.id = req.enemy;

                MsgSender.SendAll <NotifyDeath>(battle.accounts, (int)MsgID.NotifyDeath, not);
                if (battle.type == EBattle.Survival)
                {
                    SurvivalTankDeath(acc, enemy, battle);
                }
                else
                {
                    ArenaTankDeath(acc, enemy, battle);
                }
            }
        }
    }
Example #25
0
        public bool setValue(Dictionary <string, object> dict)
        {
            try
            {
                this.lbl_FpDm.Text = "发票代码:";
                this.lbl_FpHm.Text = "发票号码:";
                this.lbl_KpRq.Text = "开票日期:";
                this.lbl_GfSh.Text = "购方税号:";
                this.lbl_XfSh.Text = "销方税号:";
                this.lbl_JE.Text   = "金    额:";
                this.lbl_SE.Text   = "税    额:";
                this.lbl_ZfBz.Text = "作废标志:";
                this.lbl_BSZT.Text = "报送状态:";
                if (base.TaxCardInstance.QYLX.ISTDQY)
                {
                    this.lbl_BSZT.Visible = false;
                }
                if (dict.Count <= 0)
                {
                    base.Close();
                    this.loger.Error("发票种类、发票代码、发票号码传入失败。");
                    MessageManager.ShowMsgBox("FPCX-000022");
                    return(false);
                }
                if ((!dict.ContainsKey("lbl_FpHm") || !dict.ContainsKey("lbl_FpDm")) || ((!dict.ContainsKey("lbl_DZSYH") || !dict.ContainsKey("lbl_KPSXH")) || !dict.ContainsKey("lbl_KpRq")))
                {
                    base.Close();
                    this.loger.Error("发票种类、发票代码、发票号码传入失败。");
                    MessageManager.ShowMsgBox("FPCX-000022");
                    return(false);
                }
                InvDetail detail = base.TaxCardInstance.QueryInvInfo(dict["lbl_FpDm"].ToString(), Aisino.Fwkp.Fpkj.Common.Tool.ObjectToInt(dict["lbl_FpHm"]), dict["lbl_DZSYH"].ToString(), dict["lbl_KPSXH"].ToString(), Aisino.Fwkp.Fpkj.Common.Tool.ObjectToDateTime(dict["lbl_KpRq"]));
                if (base.TaxCardInstance.RetCode != 0)
                {
                    MessageManager.ShowMsgBox(base.TaxCardInstance.ErrCode);
                    return(false);
                }
                Fpxx fpxx = null;
                if (base.TaxCardInstance.SoftVersion != "FWKP_V2.0_Svr_Client")
                {
                    fpxx = new Fpxx();
                    fpxx.RepairInv(detail, -1);
                }
                else if (base.TaxCardInstance.SubSoftVersion != "Linux")
                {
                    fpxx = (Fpxx)SerializeUtil.Deserialize(ToolUtil.FromBase64String(detail.OldInvNo));
                }
                else
                {
                    fpxx = Fpxx.DeSeriealize_Linux(ToolUtil.FromBase64String(detail.OldInvNo));
                }
                if ((detail.TypeCode == "") && (detail.InvNo == 0))
                {
                    MessageManager.ShowMsgBox("FPCX-000031", new string[] { dict["lbl_FpDm"].ToString(), ShareMethods.FPHMTo8Wei(dict["lbl_FpHm"].ToString()) });
                    return(false);
                }
                if (!string.IsNullOrEmpty(detail.TypeCode))
                {
                    this.lbl_FpDm.Text = this.lbl_FpDm.Text + detail.TypeCode.Trim();
                }
                this.lbl_FpHm.Text = this.lbl_FpHm.Text + ShareMethods.FPHMTo8Wei(detail.InvNo);
                if (((int)fpxx.fplx == 2) && ((int)fpxx.Zyfplx == 9))
                {
                    if (!string.IsNullOrEmpty(detail.SaleTaxCode))
                    {
                        this.lbl_GfSh.Text = this.lbl_GfSh.Text + detail.SaleTaxCode.Trim();
                    }
                    if (!string.IsNullOrEmpty(detail.BuyTaxCode))
                    {
                        this.lbl_XfSh.Text = this.lbl_XfSh.Text + detail.BuyTaxCode.Trim();
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(detail.BuyTaxCode))
                    {
                        if ((detail.InvType == 12) && !fpxx.isNewJdcfp)
                        {
                            if (fpxx.sfzhm.Length > 0)
                            {
                                this.lbl_GfSh.Text = "身份证号码/组织机构代码:" + fpxx.sfzhm;
                            }
                            else
                            {
                                this.lbl_GfSh.Text = "身份证号码/组织机构代码:" + new string('0', 15);
                            }
                        }
                        else
                        {
                            this.lbl_GfSh.Text = this.lbl_GfSh.Text + detail.BuyTaxCode.Trim();
                        }
                    }
                    if (!string.IsNullOrEmpty(detail.SaleTaxCode))
                    {
                        this.lbl_XfSh.Text = this.lbl_XfSh.Text + detail.SaleTaxCode.Trim();
                    }
                }
                DateTime date = detail.Date;
                this.lbl_KpRq.Text = this.lbl_KpRq.Text + detail.Date.ToString("yyyy年MM月dd日");
                this.lbl_JE.Text   = this.lbl_JE.Text + Convert.ToString(detail.Amount.ToString("0.00"));
                this.lbl_SE.Text   = this.lbl_SE.Text + Convert.ToString(detail.Tax.ToString("0.00"));
                if (detail.CancelFlag)
                {
                    this.lbl_ZfBz.Text = this.lbl_ZfBz.Text + "是";
                }
                else
                {
                    this.lbl_ZfBz.Text = this.lbl_ZfBz.Text + "否";
                }
                string str = "未报送";
                switch (fpxx.bszt)
                {
                case 0:
                    str = "未报送";
                    break;

                case 1:
                    str = "已报送";
                    break;

                case 2:
                    str = "报送失败";
                    break;

                case 3:
                    str = "报送中";
                    break;

                case 4:
                    str = "验签失败";
                    break;

                default:
                    str = "未报送";
                    break;
                }
                this.lbl_BSZT.Text = this.lbl_BSZT.Text + str;
            }
            catch (Exception exception)
            {
                this.loger.Error(exception.Message);
                MessageManager.ShowMsgBox(exception.Message);
                return(false);
            }
            return(true);
        }
Example #26
0
        protected override bool OnHandleMessage(IMessage message, PhotonServerPeer serverPeer)
        {
            var para = new Dictionary <byte, object>
            {
                { (byte)ClientParameterCode.PeerId, message.Parameters[(byte)ClientParameterCode.PeerId] },
                { (byte)ClientParameterCode.SubOperationCode, message.Parameters[(byte)ClientParameterCode.SubOperationCode] }
            };

            var operation = new CreateCharacter(serverPeer.Protocol, message);

            if (!operation.IsValid)
            {
                Log.Error(operation.GetErrorMessage());
                serverPeer.SendOperationResponse(new OperationResponse(message.Code)
                {
                    ReturnCode   = (int)ErrorCode.OperationInvalid,
                    DebugMessage = operation.GetErrorMessage(),
                    Parameters   = para
                }, new SendParameters());
                return(true);
            }

            try
            {
                using (var session = NHibernateHelper.OpenSession())
                {
                    using (var transaction = session.BeginTransaction())
                    {
                        var user       = session.QueryOver <User>().Where(u => u.Id == operation.UserId).List().FirstOrDefault();
                        var profile    = session.QueryOver <UserProfile>().Where(up => up.UserId == user).List().FirstOrDefault();
                        var characters = session.QueryOver <ComplexCharacter>().Where(cc => cc.UserId == user).List();

                        if (profile != null && profile.CharacterSlots <= characters.Count)
                        {
                            serverPeer.SendOperationResponse(new OperationResponse(message.Code)
                            {
                                ReturnCode = (int)ErrorCode.InvalidCharacter, DebugMessage = "No free character slots", Parameters = para
                            }, new SendParameters());
                        }
                        else
                        {
                            var createCharacter = SerializeUtil.Deserialize <CharacterCreateDetails>(operation.CharacterCreateDetails);
                            Server.Log.DebugFormat("NEW CHAR: NAME: {0} / SEX: {1} / CLASS: {2}", createCharacter.CharacterName, createCharacter.Sex, createCharacter.CharacterClass);
                            var character = session.QueryOver <ComplexCharacter>().Where(cc => cc.Name == createCharacter.CharacterName).List().FirstOrDefault();
                            if (character != null)
                            {
                                transaction.Commit();
                                serverPeer.SendOperationResponse(new OperationResponse(message.Code)
                                {
                                    ReturnCode = (int)ErrorCode.InvalidCharacter, DebugMessage = "Character name taken", Parameters = para
                                }, new SendParameters());
                            }
                            else
                            {
                                var newChar = new ComplexCharacter()
                                {
                                    UserId = user,
                                    Name   = createCharacter.CharacterName,
                                    Class  = createCharacter.CharacterClass,
                                    Sex    = createCharacter.Sex,
                                    Level  = 0,
                                };
                                session.Save(newChar);
                                transaction.Commit();
                                serverPeer.SendOperationResponse(new OperationResponse(message.Code)
                                {
                                    ReturnCode = (int)ErrorCode.OK, DebugMessage = "Character successfuly created", Parameters = para
                                }, new SendParameters());
                            }
                        }
                    }
                }
                return(true);
            }

            catch (Exception e)
            {
                Log.Error(e);
                serverPeer.SendOperationResponse(new OperationResponse(message.Code)
                {
                    ReturnCode = (int)ErrorCode.InvalidCharacter, DebugMessage = e.ToString(), Parameters = para
                }, new SendParameters());
            }
            return(true);
        }
Example #27
0
    private void OnInvItemInfos(SocketModel model)
    {
        RespItemInfos resp = SerializeUtil.Deserialize <RespItemInfos>(model.message);

        WindowManager.instance.Open <InventoryWnd>().Initialize(resp.inventorys, resp.equips);
    }
Example #28
0
        /// <summary>
        /// Thực thi gọi hàm lên API
        /// </summary>
        /// <param name="funtionName"></param>
        /// <param name="parameter"></param>
        /// <param name="headers"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        public static ServiceResult ExecuteFunction(string funtionName, object parameter, Dictionary <string, string> headers = null, string method = "POST")
        {
            var result = new ServiceResult();

            try
            {
                var apiUrl = CommonKey.WebUrl;
                if (!apiUrl.EndsWith("/"))
                {
                    apiUrl += "/";
                }
                apiUrl += "api/" + funtionName;
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl);
                request.Method = method;

                // Tạo đối tượng param để send
                var sParam = string.Empty;
                if (parameter != null)
                {
                    sParam = SerializeUtil.Serialize(parameter);
                }
                var encode    = new System.Text.UTF8Encoding();
                var byteArray = encode.GetBytes(sParam);

                request.ContentLength = byteArray.Length;
                request.ContentType   = "application/json; charset=utf-8";

                if (headers != null && headers.Count > 0)
                {
                    foreach (KeyValuePair <string, string> header in headers)
                    {
                        request.Headers.Add(header.Key, header.Value);
                    }
                }

                // Truyền param vào request
                var dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        var sr           = new StreamReader(response.GetResponseStream());
                        var resultString = sr.ReadToEnd();
                        if (!string.IsNullOrWhiteSpace(resultString))
                        {
                            result = SerializeUtil.Deserialize <ServiceResult>(resultString);
                        }
                    }
                    else
                    {
                        result.Success   = false;
                        result.ErrorCode = response.StatusDescription;
                        result.Errors.Add(response.StatusDescription);
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success   = false;
                result.ErrorCode = ErrorCode.Exception;
                // Nếu không truy cập được vào Cloud
                if (ex.Message.Contains("(401) Unauthorized"))
                {
                    result.ErrorCode = ErrorCode.InvalidPassword;
                }
                result.Errors.Add(ex.Message);
            }
            return(result);
        }
Example #29
0
        private static WXSync SyncMessage()
        {
            if (InitHelper.WebWeixinInit != null)
            {
                var synckey = string.Empty;

                int count = 0;

                if (preSyncKey == null || preSyncKey.Count == 0)
                {
                    foreach (var item in InitHelper.WebWeixinInit.SyncKey.List)
                    {
                        synckey += "{\"Key\":" + item.Key + ",\"Val\":" + item.Val + "},";
                    }
                    if (!string.IsNullOrEmpty(synckey))
                    {
                        synckey = synckey.Substring(0, synckey.Length - 1);
                    }
                    count = InitHelper.WebWeixinInit.SyncKey.Count;
                }
                else if (preSyncKey.List != null && preSyncKey.List.Count > 0)
                {
                    foreach (var item in preSyncKey.List)
                    {
                        synckey += "{\"Key\":" + item.Key + ",\"Val\":" + item.Val + "},";
                    }
                    if (!string.IsNullOrEmpty(synckey))
                    {
                        synckey = synckey.Substring(0, synckey.Length - 1);
                    }
                    count = preSyncKey.Count;
                }


                var json = "{\"BaseRequest\":{\"Uin\":" + LoginHelper.LoginPageCookie.wxuin + ",\"Sid\":\"" + LoginHelper.LoginPageCookie.wxsid + "\",\"Skey\":\"" + LoginHelper.LoginPageXml.skey + "\",\"DeviceID\":\"e370515259583130\"},\"SyncKey\":{\"Count\":" + count + ",\"List\":[" + synckey + "]},\"rr\":-" + CalcTimeUtil.GetUnixDateTime() + "}";


                var reqCookies = new CookieContainer();
                reqCookies.Add(new Cookie("pgv_pvi", LoginHelper.pgv_pvi, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("pgv_si", LoginHelper.pgv_si, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("refreshTimes", "2", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("MM_WX_NOTIFY_STATE", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("MM_WX_SOUND_STATE", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("mm_lang", "zh_CN", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwxuvid", LoginHelper.LoginPageCookie.webwxuvid, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwx_auth_ticket", LoginHelper.LoginPageCookie.webwx_auth_ticket, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwx_data_ticket", LoginHelper.LoginPageCookie.webwx_data_ticket, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("login_frequency", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("last_wxuin", "LoginHelper.LoginPageCookie.wxuin", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxloadtime", "1495855277_expired", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxsid", LoginHelper.LoginPageCookie.wxsid, "/", "wx.qq.com"));

                CookieContainer resCookies = null;

                var SyncUrl = string.Format(SyncUrlTemple, LoginHelper.LoginPageCookie.wxsid, LoginHelper.LoginPageXml.skey, LoginHelper.LoginPageXml.pass_ticket);

                if (LoginHelper.WX2)
                {
                    SyncUrl = SyncUrl.Replace("//wx.", "//wx2.");
                }

                var dic = new Dictionary <string, string>();

                dic.Add(WebClientUtil.JsonDataPrex, json);

                return(SerializeUtil.Deserialize <WXSync>(WebClientUtil.GetResponseOnCookie(SyncUrl, "post", reqCookies, out resCookies, dic, "application/json;charset=UTF-8")));
            }
            return(null);
        }
Example #30
0
    private void OnMallInfoRsp(SocketModel model)
    {
        RspMallInfo rsp = SerializeUtil.Deserialize <RspMallInfo>(model.message);

        WindowManager.instance.Open <MallWnd>().Init(rsp.goods);
    }