Exemplo n.º 1
0
    /// <summary>
    /// Approves the friendship. Called when the "Approve friendship" button is pressed.
    /// Expects the RequestFriendship method to be run first.
    /// </summary>
    private bool ApproveFriendship()
    {
        // Get the users involved in the friendship
        UserInfo user   = MembershipContext.AuthenticatedUser;
        UserInfo friend = UserInfoProvider.GetUserInfo("MyNewFriend");

        if (friend != null)
        {
            // Get the friendship with current user
            FriendInfo updateFriendship = FriendInfoProvider.GetFriendInfo(user.UserID, friend.UserID);
            if (updateFriendship != null)
            {
                // Set its properties
                updateFriendship.FriendStatus       = FriendshipStatusEnum.Approved;
                updateFriendship.FriendRejectedBy   = 0;
                updateFriendship.FriendApprovedBy   = user.UserID;
                updateFriendship.FriendApprovedWhen = DateTime.Now;

                // Save the changes to database
                FriendInfoProvider.SetFriendInfo(updateFriendship);

                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 2
0
 public virtual void Init(FriendInfo info)
 {
     var tmpl = HeroModelLocator.Instance.HeroTemplates.HeroTmpls;
     var leaderTmplID = info.HeroProp[0].HeroTemplateId;
     FriendInfo = info;
     nameLbl.text = info.FriendName;
     atkLbl.text = FriendUtils.GetProp(info, RoleProperties.ROLE_ATK).ToString();
     hpLbl.text = FriendUtils.GetProp(info, RoleProperties.ROLE_HP).ToString();
     lvlLbl.text = info.FriendLvl.ToString();
     if (icon)
     {
         icon.spriteName = HeroConstant.IconIdPrefix + tmpl[leaderTmplID].Icon;
     }
     if (jobIcon)
     {
         jobIcon.spriteName = HeroConstant.HeroJobPrefix + tmpl[leaderTmplID].Job;
     }
     if (bindIcon)
     {
         bindIcon.enabled = FriendUtils.IsFriendBind(info);
     }
     if (longPress)
     {
         longPress.OnLongPress = OnLongPress;
         longPress.OnLongPressFinish = OnLongPressFinish;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 实例化好友消息名单
 /// </summary>
 /// <param name="info"></param>
 /// <param name="insert">是否写入本地聊天记录</param>
 private void SetFriendRelevantInfo(FriendInfo info)
 {
     //如果本地已经存在UI
     if (UI_ChatPanelManagers.GetChatPanelInstance.ui_ChatPanels.ContainsKey(info.friend_id))
     {
         //实例话消息
         foreach (FriendInfo.Content content in info.chat_message)
         {
             if (content.type == 0)
             {
                 UI_ChatPanelManagers.GetChatPanelInstance.ui_ChatPanels[info.friend_id].CreateMyselfMsgText(content.msg);
             }
             else
             {
                 UI_ChatPanelManagers.GetChatPanelInstance.ui_ChatPanels[info.friend_id].CreateFriendMsgText(content.msg);
             }
         }
     }
     else
     {
         //实例聊天消息UI
         Prefab_FriendMsg friend = Instantiate(friendMsgPrefap, content.position, Quaternion.identity).GetComponent <Prefab_FriendMsg>();
         //设置好友信息
         friend.friendinfo = info;
         //设置父级
         friend.transform.SetParent(content);
     }
 }
Exemplo n.º 4
0
        public static FriendDetailView Open(FriendInfo info)
        {
            FriendDetailView view = UIMgr.instance.Open <FriendDetailView>(PREFAB_PATH, EUISortingLayer.Tips);

            view.SetFriendInfo(info);
            return(view);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //①読み込むJSONデータ
            var jsonString = @"{""Address"":""Tokyo"",""Age"":32,""Name"":""Doi""}";
            //②DynamicJsonクラスのParseメソッドでJSONデータを解析してdynamic型として返す
            var obj = DynamicJson.Parse(jsonString);
            //③変換したクラスのプロパティ内容を確認
            Console.WriteLine("Name:{0}, Address:{1}, Age:{2}", obj.Name, obj.Address, obj.Age);

            var friend = new FriendInfo()
            {
                Name = "Doi",
                Address = "Tokyo",
                Age = 32
            };
            //DynamicJsonクラスのSerializeメソッドで.NETオブジェクトをJSONデータに変換
            Console.Write(DynamicJson.Serialize(friend));

            //DynamicJsonクラスをインスタンス化
            dynamic obj2 = new DynamicJson();
            //任意のプロパティを設定可能
            obj2.Name = "Doi";
            obj2.TelNo = "03-xxxx-xxxx";
            obj2.MobileTelNo = "090-xxxx-xxxx";
            //DynamicJsonオブジェクトのToStringメソッドでJSONデータを出力
            Console.WriteLine(obj2.ToString());

            PostalCodeSample();
        }
Exemplo n.º 6
0
    /// <summary>
    /// Gets and bulk updates friends. Called when the "Get and bulk update friends" button is pressed.
    /// Expects the RequestFriendship method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateFriends()
    {
        // Get the user
        UserInfo friend = UserInfoProvider.GetUserInfo("MyNewFriend");

        if (friend != null)
        {
            // Prepare the parameters
            string where = "FriendRequestedUserID = " + friend.UserID;

            // Get the data
            DataSet friends = FriendInfoProvider.GetFriends(where, null);
            if (!DataHelper.DataSourceIsEmpty(friends))
            {
                // Loop through the individual items
                foreach (DataRow friendDr in friends.Tables[0].Rows)
                {
                    // Create object from DataRow
                    FriendInfo modifyFriend = new FriendInfo(friendDr);

                    // Update the properties
                    modifyFriend.FriendStatus       = FriendshipStatusEnum.Approved;
                    modifyFriend.FriendRejectedBy   = 0;
                    modifyFriend.FriendApprovedBy   = MembershipContext.AuthenticatedUser.UserID;
                    modifyFriend.FriendApprovedWhen = DateTime.Now;

                    // Save the changes
                    FriendInfoProvider.SetFriendInfo(modifyFriend);
                }

                return(true);
            }
        }
        return(false);
    }
Exemplo n.º 7
0
        public override List <FriendInfo> this[UGUI user]
        {
            get
            {
                var friends = new List <FriendInfo>();

                RwLockedDictionary <UUID, FriendData> friendList;
                if (!m_Friends.TryGetValue(user.ID, out friendList))
                {
                    return(friends);
                }

                foreach (var kvp in friendList)
                {
                    var fi = new FriendInfo();
                    RwLockedDictionary <UUID, FriendData> otherFriendList;
                    FriendData otherFriendData;
                    if (m_Friends.TryGetValue(kvp.Key, out otherFriendList) &&
                        otherFriendList.TryGetValue(user.ID, out otherFriendData))
                    {
                        fi.UserGivenFlags = otherFriendData.Rights;
                    }
                    fi.FriendGivenFlags = kvp.Value.Rights;
                    fi.Secret           = kvp.Value.Secret;
                    fi.Friend.ID        = kvp.Key;
                    fi.User             = user;
                    friends.Add(fi);
                }
                return(friends);
            }
        }
Exemplo n.º 8
0
 public unsafe void GetFriends(Action <bool> callback)
 {
     if (CheckAndSetActionExecuting())
     {
         OnActionCallback = delegate(bool success, string data)
         {
             if (success)
             {
                 try
                 {
                     friendInfo = JsonUtility.FromJson <FriendInfo>(data);
                     callback(true);
                 }
                 catch (Exception)
                 {
                     callback(false);
                 }
             }
             else
             {
                 callback(false);
             }
         };
         FB.API("/me/friends?fields=id,name,picture&pretty=0&limit=5000", 0, new FacebookDelegate <IGraphResult>((object)this, (IntPtr)(void *) /*OpCode not supported: LdFtn*/), (IDictionary <string, string>)null);
     }
 }
Exemplo n.º 9
0
 private void Start()
 {
     agent      = GetComponent <NavMeshAgent>();
     friendGun  = GetComponent <FriendGun>();
     friendInfo = GetComponent <FriendInfo>();
     //agent.SetDestination(agent.transform.position);
 }
Exemplo n.º 10
0
        public void upload(Action <UploadFriendsInfoData> callBack, Action <ResponseErroInfo> errCallBack)
        {
            string currentChildSN = mLocalChildInfoAgent.getChildSN();

            if (currentChildSN == string.Empty)
            {
                errCallBack(ResponseErroInfo.GetErrorInfo(0, "upload resource is empty"));
                return;
            }
            List <FriendInfoItem> info = mLocalAddFriendsInfo.getAllAddedFriendsInfo(currentChildSN);

            if (info != null && info.Count > 0)
            {
                FriendInfo mFriendInfo = new FriendInfo();
                mFriendInfo.logs = info;

                mUploadChildFriendsService.uploadChildFriendsinfo(mFriendInfo, currentChildSN, (cb) =>
                {
                    Debug.Log("uploadChildFriendsinfo: success");
                    mLocalAddFriendsInfo.deleteAddedFriendsInfo(currentChildSN);
                    callBack(cb);
                }, (ecb) =>
                {
                    Debug.Log("uploadChildFriendsinfo: error");
                    errCallBack(ecb);
                });
            }
            else
            {
                errCallBack(ResponseErroInfo.GetErrorInfo(0, "upload resource is empty"));
            }
        }
Exemplo n.º 11
0
    public void FriendWindow(FriendInfo f)
    {
        win.ShowWindow(delegate
        {
            bool inFr = bs._Loader.friends.Contains(f.Name);

            Label("Name: " + f.Name);
            Label("Status: " + (f.IsOnline ? "Online" : "Offline"));
            if (f.IsInRoom)
            {
                gui.BeginHorizontal();
                Label("Room:" + f.Room);
                if (inFr && Button("Join"))
                {
                    hostRoom = PhotonNetwork.GetRoomList().FirstOrDefault(a => a.name == f.Room);
                    _Loader.StartCoroutine(_Loader.LoadLevel(false));
                }
                gui.EndHorizontal();
            }
            if (!inFr)
            {
                if (Button("Add to friends"))
                {
                    AddFriend(f.Name);
                }
            }
            else
            if (Button("Remove from friends"))
            {
                RemoveFriend(f.Name);
            }
        });
    }
Exemplo n.º 12
0
    /// <summary>
    /// 1、在线状态
    /// 2、友好度高的排列靠前
    /// 3、友好度一致时队伍ID由低到高排列
    /// --玩家状态
    //PlayerState =
    //{
    //    NONE		= 0, --NONE
    //    NORMAL		= 1, --正常
    //    MATCH		= 2, --比赛匹配中
    //    GAME		= 3, --比赛中
    //    LOGOUT		= 4, --登出
    //    OFFLINE		= 5, --离线
    //    ROOM		= 8, --房间内
    //    CREATEGAME	= 9, --创建比赛中
    //    RECHARGE	= 10, --充值
    //    READYGAME	= 11, --准备进比赛中
    //    SELECTROLE	= 12, --选择球员进行比赛中
    //}
    /// </summary>
    /// <param name="AF1"></param>
    /// <param name="AF2"></param>
    /// <returns></returns>
    private static int SortFriendList(FriendInfo AF1, FriendInfo AF2)
    {
        uint a1 = (AF1.online == 5) ? 0u : 1u;
        uint a2 = (AF2.online == 5) ? 0u : 1u;

        if (a1 > a2)
        {
            return(-1);
        }
        else if (a1 < a2)
        {
            return(1);
        }

        if (AF1.shinwakan > AF2.shinwakan)
        {
            return(-1);
        }
        else if (AF1.shinwakan < AF2.shinwakan)
        {
            return(1);
        }

        if (AF1.acc_id < AF2.acc_id)
        {
            return(-1);
        }
        else if (AF1.acc_id > AF2.acc_id)
        {
            return(1);
        }

        return(0);
    }
Exemplo n.º 13
0
    public void Set(FriendInfo fi)
    {
        CurFI = fi;

        Name.text = CurFI.Name;

        int        RoleID = Math.Max(fi.RoleID, 1);
        RoleConfig rc     = null;

        if (CsvConfigTables.Instance.RoleCsvDic.TryGetValue(RoleID, out rc))
        {
            HeadPortrait.spriteName = rc.Portrait;
        }

        StageConfig sc = null;

        CsvConfigTables.Instance.StageCsvDic.TryGetValue(CurFI.StageProgress, out sc);
        if (sc != null)
        {
            ChapterConfig cc = null;
            CsvConfigTables.Instance.ChapterCsvDic.TryGetValue(sc.ChapterID, out cc);

            GroupConfig gc = null;
            CsvConfigTables.Instance.GroupCsvDic.TryGetValue(sc.GroupID, out gc);
            if (cc != null && gc != null)
            {
                Stage.text = StringBuilderTool.ToInfoString(cc.Name, "-", gc.Name, "-", sc.Name);
            }
        }
    }
Exemplo n.º 14
0
        public async Task <FriendInfo> GetFriendInfo(long id)
        {
            FriendInfo info = new FriendInfo(id, await _redis.GetHashAllAsync <long, OneFriendInfo>
                                                 (KeyGenHelper.GenUserKey(id, "FriendInfo")));

            return(info);
        }
Exemplo n.º 15
0
    public void setLookButton(FriendInfo infoc)
    {
        bool isfriend = SdkFriendManager.Instance.isSdkFriend(infoc.getplatUid());

        isfriend = SdkFriendManager.Instance.IsContentFriendUid(infoc.getUid()) == true ? true : isfriend;
        disableButton(isfriend);
    }
Exemplo n.º 16
0
        private void SetControls()
        {
            if (listFriends.SelectedItems.Count == 0)
            {
                pnlActions.Enabled = pnlFriendsRights.Enabled = false;
            }
            else if (listFriends.SelectedItems.Count == 1)
            {
                pnlActions.Enabled = pnlFriendsRights.Enabled = true;
                btnProfile.Enabled = btnIM.Enabled = btnPay.Enabled = btnRemove.Enabled = true;

                FriendInfo friend = (FriendInfo)listFriends.SelectedItems[0];
                lblFriendName.Text = friend.Name + (friend.IsOnline ? " (online)" : " (offline)");

                settingFriend              = true;
                chkSeeMeOnline.Checked     = friend.CanSeeMeOnline;
                chkSeeMeOnMap.Checked      = friend.CanSeeMeOnMap;
                chkModifyMyObjects.Checked = friend.CanModifyMyObjects;
                settingFriend              = false;
            }
            else
            {
                btnIM.Enabled            = pnlActions.Enabled = true;
                pnlFriendsRights.Enabled = false;
                btnProfile.Enabled       = btnPay.Enabled = btnRemove.Enabled = false;
                lblFriendName.Text       = "Multiple friends selected";
            }
        }
Exemplo n.º 17
0
 private void Start()
 {
     gun          = GetComponent <FriendGun>();
     navigation   = GetComponent <FriendNavigation>();
     friendInfo   = GetComponent <FriendInfo>();
     navMeshAgent = GetComponent <NavMeshAgent>();
 }
Exemplo n.º 18
0
    // =========================================================================================================================
    // === debug ===============================================================================================================
#if UNITY_EDITOR
    void Debug_GenerateRandomFriends(bool inActive)
    {
        if (inActive == true)
        {
            m_Friends.Clear();
            for (int i = 0; i < 10; i++)
            {
                FriendInfo friend = new FriendInfo();
                friend.PrimaryKey = MFDebugUtils.GetRandomString(Random.Range(5, 12));
                //friend.m_Level        = Random.Range(1,20);
                //friend.m_Missions	= Random.Range(0,200);
                friend.LastOnlineDate = 0;                 //MiscUtils.RandomValue( new string[] {"unknown", "yesterday", "tomorrow"});
                m_Friends.Add(friend);
            }
        }
        else
        {
            m_PendingFriends.Clear();
            for (int i = 0; i < 10; i++)
            {
                PendingFriendInfo friend = new PendingFriendInfo();
                friend.PrimaryKey = MFDebugUtils.GetRandomString(Random.Range(5, 12));
                friend.AddedDate  = GuiBaseUtils.DateToEpoch(CloudDateTime.UtcNow);

                if (Random.Range(0, 2) == 0)
                {
                    // create dummy message, for testing gui behavior...
                    friend.CloudCommand = MFDebugUtils.GetRandomString(Random.Range(512, 512));
                }

                m_PendingFriends.Add(friend);
            }
        }
    }
Exemplo n.º 19
0
    protected void btnRemoveSelected_Click(object sender, EventArgs e)
    {
        // If there user selected some items
        if (gridElem.SelectedItems.Count > 0)
        {
            RaiseOnCheckPermissions(PERMISSION_MANAGE, this);

            // Get all needed friendships
            DataSet friendships = FriendInfoProvider.GetFriends()
                                  .WhereIn("FriendID", gridElem.SelectedItems.Select(id => ValidationHelper.GetInteger(id, 0)).ToList());

            if (!DataHelper.DataSourceIsEmpty(friendships))
            {
                // Delete all these friendships
                foreach (DataRow friendship in friendships.Tables[0].Rows)
                {
                    FriendInfo fi = new FriendInfo(friendship);
                    if (fi.FriendStatus != FriendshipStatusEnum.Rejected)
                    {
                        FriendInfoProvider.DeleteFriendInfo(fi);
                    }
                }
            }
            gridElem.ResetSelection();
            // Reload grid
            gridElem.ReloadData();
        }
    }
Exemplo n.º 20
0
        public override void OnInvoke(object sender, System.EventArgs e, object target)
        {
            ListViewItem ali      = target as ListViewItem;
            string       username = null;
            UUID         uuid     = UUID.Zero;

            if (ali != null)
            {
                uuid     = (UUID)ali.Tag;
                username = instance.Names.Get(uuid);
            }
            else
            {
                FriendInfo fi = target as FriendInfo;
                uuid     = fi.UUID;
                username = instance.Names.Get(uuid);
            }
            if (username == null)
            {
                instance.TabConsole.DisplayNotificationInChat("I dont know how to DeRef " + target + " bieng a  " +
                                                              target.GetType());
                return;
            }
            string outp = username + ", " + aimlBot.Chat("INTERJECTION", username).Output;

            if (outp.Length > 1000)
            {
                outp = outp.Substring(0, 1000);
            }

            Client.Self.Chat(outp, 0, ChatType.Normal);
        }
Exemplo n.º 21
0
        private void HandleOnFriendOffline(JsonMessage lobbyMsg)
        {
            UserInfo playerself = WorldSystem.Instance.GetPlayerSelf();

            if (null == playerself)
            {
                return;
            }
            JsonData jsonData = lobbyMsg.m_JsonData;

            ArkCrossEngineMessage.Msg_LC_FriendOffline protoData = lobbyMsg.m_ProtoData as ArkCrossEngineMessage.Msg_LC_FriendOffline;
            if (null != protoData)
            {
                ulong friend_guid = protoData.m_Guid;
                if (null != LobbyClient.Instance.CurrentRole)
                {
                    Dictionary <ulong, FriendInfo> friends = LobbyClient.Instance.CurrentRole.Friends;
                    if (null != friends && friends.Count > 0)
                    {
                        FriendInfo out_info = null;
                        if (friends.TryGetValue(friend_guid, out out_info))
                        {
                            out_info.IsOnline = false;
                            GfxSystem.PublishGfxEvent("ge_friend_offline", "friend", friend_guid);
                        }
                    }
                }
            }
        }
    public void FriendWindow(FriendInfo f)
    {
        win.ShowWindow(delegate
        {
            bool inFr = bs._Loader.friends.Contains(f.Name);

            Label("Name: " + f.Name);
            Label("Status: " + (f.IsOnline ? "Online" : "Offline"));
            if (f.IsInRoom)
            {
                gui.BeginHorizontal();
                Label("Room:" + f.Room);
                if (inFr && Button("Join"))
                {
                    hostRoom = PhotonNetwork.GetRoomList().FirstOrDefault(a => a.name == f.Room);
                    _Loader.StartCoroutine(_Loader.LoadLevel(false));
                }
                gui.EndHorizontal();
            }
            if (!inFr)
            {
                if (Button("Add to friends"))
                    AddFriend(f.Name);
            }
            else
                if (Button("Remove from friends"))
                RemoveFriend(f.Name);
        });
    }
Exemplo n.º 23
0
        private void HandleQueryFriendInfoResult(JsonMessage lobbyMsg)
        {
            UserInfo playerself = WorldSystem.Instance.GetPlayerSelf();

            if (null == playerself)
            {
                return;
            }
            JsonData jsonData = lobbyMsg.m_JsonData;

            ArkCrossEngineMessage.Msg_LC_QueryFriendInfoResult protoData = lobbyMsg.m_ProtoData as ArkCrossEngineMessage.Msg_LC_QueryFriendInfoResult;
            if (null != protoData)
            {
                List <FriendInfo> friend_list = new List <FriendInfo>();
                int ct = protoData.m_Friends.Count;
                for (int i = 0; i < ct; i++)
                {
                    FriendInfo assit_info = new FriendInfo();
                    assit_info.Guid          = protoData.m_Friends[i].Guid;
                    assit_info.Nickname      = protoData.m_Friends[i].Nickname;
                    assit_info.HeroId        = protoData.m_Friends[i].HeroId;
                    assit_info.Level         = protoData.m_Friends[i].Level;
                    assit_info.FightingScore = protoData.m_Friends[i].FightingScore;
                    assit_info.IsOnline      = protoData.m_Friends[i].IsOnline;
                    assit_info.IsBlack       = protoData.m_Friends[i].IsBlack;
                    friend_list.Add(assit_info);
                }
                GfxSystem.PublishGfxEvent("ge_query_friend_result", "friend", friend_list);
            }
        }
Exemplo n.º 24
0
    public void updateFacebookFriendPicture(FriendInfo friendInfo)
    {
        fbPicture      = facebookBackground.GetComponent <FBPicture>();
        fbPicture.fbId = friendInfo.facebookID;

        Invoke("pictureRequest", 0.1f);
    }
Exemplo n.º 25
0
        public async Task AddPlatformFriend(string platformAccount, int type, FriendInfo friendInfo)
        {
            //查询该玩家是否是注册玩家

            var response = await _mqGetIdCleint.GetResponseExt <GetIdByPlatformMqCommand, BodyResponse <GetIdByPlatformMqResponse> >
                               (new GetIdByPlatformMqCommand(platformAccount, type));

            if (response.Message.StatusCode != StatusCodeDefines.Success)
            {
                return;
            }
            long friendId = response.Message.Body.Id;

            if (friendInfo._friends == null || !friendInfo._friends.TryGetValue(friendId, out var info))
            {
                using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(friendId, "FriendInfo")))
                {
                    await AddFriend(friendInfo.Id, friendId, FriendTypes.PlatformFriend);

                    return;
                }
            }
            if (info.Type != FriendTypes.PlatformFriend)
            {
                using (var locker = _redis.Locker(KeyGenHelper.GenUserKey(friendId, "FriendInfo")))
                {
                    await _redis.DeleteFriend(friendInfo.Id, friendId);

                    await Task.WhenAll(_redis.AddFriend(friendInfo.Id, friendId, FriendTypes.PlatformFriend),
                                       _friendRepository.UpdateFriend(friendInfo.Id, friendId, FriendTypes.PlatformFriend));
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Respond to a "Speech..." context menu action
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="target"></param>
        public override void OnInvoke(object sender, EventArgs e, object target)
        {
            string name;
            UUID   id;

            // This action applies to avatars, which can come in
            // various forms.
            if (target is FriendInfo)
            {
                FriendInfo f = target as FriendInfo;
                name = f.Name;
                id   = f.UUID;
            }
            else if (target is Avatar)
            {
                Avatar a = target as Avatar;
                name = a.Name;
                id   = a.ID;
            }
            else if (target is ListViewItem)
            {
                ListViewItem i = target as ListViewItem;
                id   = (UUID)i.Tag;
                name = control.instance.Names.Get(id);
            }
            else
            {
                return;
            }

            Form va =
                new VoiceAssignment(control, name, id);

            va.Show();
        }
 protected void btnRemoveSelected_Click(object sender, EventArgs e)
 {
     // If there user selected some items
     if (gridElem.SelectedItems.Count > 0)
     {
         RaiseOnCheckPermissions(PERMISSION_MANAGE, this);
         // Create where condition
         string where = "FriendID IN (";
         foreach (object friendId in gridElem.SelectedItems)
         {
             where += ValidationHelper.GetInteger(friendId, 0) + ",";
         }
         where = where.TrimEnd(',') + ")";
         // Get all needed friendships
         DataSet friendships = FriendInfoProvider.GetFriends(where, null);
         if (!DataHelper.DataSourceIsEmpty(friendships))
         {
             // Delete all these friendships
             foreach (DataRow friendship in friendships.Tables[0].Rows)
             {
                 FriendInfo fi = new FriendInfo(friendship);
                 if (fi.FriendStatus != FriendshipStatusEnum.Rejected)
                 {
                     FriendInfoProvider.DeleteFriendInfo(fi);
                 }
             }
         }
         gridElem.ResetSelection();
         // Reload grid
         gridElem.ReloadData();
     }
 }
Exemplo n.º 28
0
    public void Init(FriendInfo friend)
    {
        _didCustomTagsChange = false;
        ClearAllTagUI();

        DisplayName.text             = string.IsNullOrEmpty(friend.TitleDisplayName) ? friend.Username : friend.TitleDisplayName;
        UserName.text                = string.IsNullOrEmpty(friend.Username) ? "________" : friend.Username;
        PlayFabID.text               = friend.FriendPlayFabId;
        Origin.text                  = friend.FacebookInfo != null ? "Facebook" : "PlayFab";
        RemoveFriendBtn.interactable = friend.FacebookInfo == null;

        activeFriend = friend;
        if (friend.Tags != null)
        {
            for (var z = 0; z < friend.Tags.Count; z++)
            {
                AddTagItemUI(tag, z);
            }
        }

        if (friend.FacebookInfo != null && !string.IsNullOrEmpty(friend.FacebookInfo.FacebookId))
        {
            UnityAction <Texture2D> afterGetPhoto = tx =>
            {
                ProfilePhoto.overrideSprite = Sprite.Create(tx, new Rect(0, 0, 128, 128), new Vector2());
            };

            StartCoroutine(FacebookHelperClass.GetFriendProfilePhoto(friend.FacebookInfo.FacebookId, FetchWebAsset, afterGetPhoto));
        }
        else
        {
            ProfilePhoto.overrideSprite = null;
        }
    }
Exemplo n.º 29
0
        public static FriendList GetFriendList(long AccountId)
        {
            var friendList = new FriendList();

            friendList.IsDelta = false;
            friendList.Friends = new Dictionary <long, FriendInfo>();

            foreach (var item in MySQLDB.GetInstance().Query($"SELECT Users.AccountId, Users.UserName, Users.BannerForegroundId as EmblemId, Users.BannerBackgroundId as BannerID, Users.SelectedTitleId as TitleId, Users.RibbonId, FriendList.FriendStatus FROM FriendList INNER JOIN Users ON(Users.AccountId = AccountID_1 or Users.AccountId = AccountID_2) AND Users.AccountID <> {AccountId} WHERE AccountID_1 = {AccountId} or (AccountID_2 = {AccountId} and FriendStatus=1) ORDER BY FriendStatus", new object[] {}))
            {
                var info = new FriendInfo()
                {
                    FriendAccountId = item.GetInt32(0),
                    FriendHandle    = item.GetString(1),
                    IsOnline        = true,
                    FriendStatus    = (FriendStatus)item.GetByte(6),
                    BannerID        = item.GetInt16(3),
                    EmblemID        = item.GetInt16(2),
                    TitleID         = item.GetInt16(4),
                    RibbonID        = item.GetInt16(5),
                    StatusString    = "Online"
                };
                friendList.Friends[info.FriendAccountId] = info;
            }

            return(friendList);
        }
Exemplo n.º 30
0
    /// <summary>
    /// Creates friend. Called when the "Create friend" button is pressed.
    /// </summary>
    private bool RequestFriendship()
    {
        // First create a new user which the friendship request will be sent to
        UserInfo newFriend = new UserInfo();

        newFriend.UserName = "******";
        newFriend.FullName = "My new friend";
        newFriend.UserGUID = Guid.NewGuid();

        UserInfoProvider.SetUserInfo(newFriend);

        // Create new friend object
        FriendInfo newFriendship = new FriendInfo();

        // Set the properties
        newFriendship.FriendUserID          = MembershipContext.AuthenticatedUser.UserID;
        newFriendship.FriendRequestedUserID = newFriend.UserID;
        newFriendship.FriendRequestedWhen   = DateTime.Now;
        newFriendship.FriendComment         = "Sample friend request comment.";
        newFriendship.FriendStatus          = FriendshipStatusEnum.Waiting;
        newFriendship.FriendGUID            = Guid.NewGuid();

        // Save the friend
        FriendInfoProvider.SetFriendInfo(newFriendship);

        return(true);
    }
Exemplo n.º 31
0
    void LeaveChat(int friendIdx, bool informOtherSide)
    {
        if (friendIdx < 0 || friendIdx >= m_Friends.Count)
        {
            return;
        }

        FriendInfo info = m_Friends[friendIdx];

        m_Friends.RemoveAt(friendIdx);
        if (info == null)
        {
            return;
        }

        if (informOtherSide == true && info.IsJoined == true)
        {
            var result = new
            {
                master = info.Master,
                slave  = info.Slave
            };
            LobbyClient.SendMessageToPlayer(info.Master == m_PrimaryKey ? info.Slave : info.Master, CMD_LEAVE, JsonMapper.ToJson(result));
        }

        Chat.Unregister(info.Channel, this);

        info.Master = null;
        info.Slave  = null;

        ActivateChat(Mathf.Min(friendIdx, m_Friends.Count - 1));
    }
 protected void btnRemoveSelected_Click(object sender, EventArgs e)
 {
     // If there user selected some items
     if (gridElem.SelectedItems.Count > 0)
     {
         RaiseOnCheckPermissions(PERMISSION_MANAGE, this);
         // Create where condition
         string where = "FriendID IN (";
         foreach (object friendId in gridElem.SelectedItems)
         {
             where += ValidationHelper.GetInteger(friendId, 0) + ",";
         }
         where = where.TrimEnd(',') + ")";
         // Get all needed friendships
         DataSet friendships = FriendInfoProvider.GetFriends(where, null);
         if (!DataHelper.DataSourceIsEmpty(friendships))
         {
             // Delete all these friendships
             foreach (DataRow friendship in friendships.Tables[0].Rows)
             {
                 FriendInfo fi = new FriendInfo(friendship);
                 if (fi.FriendStatus != FriendshipStatusEnum.Rejected)
                 {
                     FriendInfoProvider.DeleteFriendInfo(fi);
                 }
             }
         }
         gridElem.ResetSelection();
         // Reload grid
         gridElem.ReloadData();
     }
 }
Exemplo n.º 33
0
    void OnChatStart(string primaryKey, string messageId, string messageText)
    {
        JsonData data   = JsonMapper.ToObject(messageText);
        string   master = data["master"].ToString();
        string   slave  = data["slave"].ToString();

        var  friend   = GameCloudManager.friendList.friends.Find(obj => obj.PrimaryKey == master);
        bool isFriend = friend != null ? true : false;

        primaryKey = m_PrimaryKey == master ? slave : master;
        FriendInfo info = m_Friends.Find(obj => obj.PrimaryKey == primaryKey);

        if (GuiFrontendMain.IsVisible == false || isFriend == false || JoinChat(master, slave, false) == false)
        {
            var result = new
            {
                master = master,
                slave  = slave
            };
            LobbyClient.SendMessageToPlayer(master == m_PrimaryKey ? slave : master, CMD_FAILED, JsonMapper.ToJson(result));
        }
        else
        {
            if (info == null)
            {
                info = m_Friends.Find(obj => obj.PrimaryKey == primaryKey);
                AddSystemMessage(info, string.Format(TextDatabase.instance[0506011], GuiBaseUtils.FixNameForGui(info.Nickname)));
            }
        }
    }
Exemplo n.º 34
0
    //..........................................................................................................................
    public void ProcessMessage(CloudMailbox.BaseMessage inMessage)
    {
        // add into pending friends..
        CloudMailbox.FriendRequest req = inMessage as CloudMailbox.FriendRequest;
        if (req != null)
        {
            FriendInfo fInfo = m_Friends.Find(f => f.PrimaryKey == inMessage.m_Sender);
            if (fInfo != null)
            {
                //Debug.Log("User with name " + inMessage.m_Sender + " is already your friend");
                return;
            }

            List <PendingFriendInfo> pfInfo = m_PendingFriends.FindAll(f => f.PrimaryKey == inMessage.m_Sender);
            if (pfInfo != null && pfInfo.Count > 0)
            {
                foreach (PendingFriendInfo p in pfInfo)
                {
                    if (p != null && p.IsItRequest == true)
                    {
                        //Debug.Log("Request from this person is already in pending list");
                        return;
                    }
                }
            }

            PendingFriendInfo friend = new PendingFriendInfo();
            friend.PrimaryKey   = req.m_Sender;
            friend.Nickname     = req.m_NickName;
            friend.Username_New = req.m_Username;
            friend.AddedDate    = GuiBaseUtils.DateToEpoch(inMessage.m_SendTime);
            friend.Message      = inMessage.m_Message;
            friend.CloudCommand = req.m_ConfirmCommand;

            m_PendingFriends.Add(friend);
            OnPendingFriendListChanged();
            Save();
            return;
        }

        CloudMailbox.FriendRequestReject reject = inMessage as CloudMailbox.FriendRequestReject;
        if (reject != null)
        {
            // remove this friend from pending list if it is still there.
            List <PendingFriendInfo> pfInfo = m_PendingFriends.FindAll(friend => friend.PrimaryKey == inMessage.m_Sender);
            if (pfInfo != null && pfInfo.Count > 0)
            {
                foreach (PendingFriendInfo p in pfInfo)
                {
                    m_PendingFriends.Remove(p);
                }
            }

            OnPendingFriendListChanged();
            Save();
            return;
        }

        Debug.LogError("Unknown message " + inMessage + " " + inMessage.msgType);
    }
Exemplo n.º 35
0
 public void Init(FriendInfo info, UIEventListener.VoidDelegate rejectDel, UIEventListener.VoidDelegate agreeDel)
 {
     base.Init(info);
     var loginDateTime = Utils.ConvertFromJavaTimestamp(info.LastLoginTime);
     loginLbl.text = Utils.GetTimeUntilNow(loginDateTime);
     rejectLis.onClick = rejectDel;
     agreeLis.onClick = agreeDel;
 }
Exemplo n.º 36
0
 /// <summary>
 /// Read this whole class from string.
 /// </summary>
 /// <param name="value"></param>
 public void ReadClass(string value)
 {
     string[] splitStrings=new string[]{DataClassName};
     string[] outStrings = value.Split(splitStrings, StringSplitOptions.RemoveEmptyEntries);
     PersistenceFileIOHandler.CheckCount(outStrings,FieldCount);
     Data=new FriendInfo();
     Data.ReadClass(outStrings[0]);
 }
Exemplo n.º 37
0
 public void Init(FriendInfo info, UIEventListener.VoidDelegate dDelegate)
 {
     base.Init(info);
     var loginDateTime = Utils.ConvertFromJavaTimestamp(info.LastLoginTime);
     loginLbl.text = Utils.GetTimeUntilNow(loginDateTime);
     var givenTime = Utils.ConvertFromJavaTimestamp(info.GiveEnergyTime);
     givenBtnSprite.isEnabled = givenBtn.isEnabled = !Utils.IsSameDay(givenTime, DateTime.Today);
     givenLis.onClick = dDelegate;
     delegateCached = dDelegate;
 }
Exemplo n.º 38
0
 private void OnEnable()
 {
     MtaManager.TrackBeginPage(MtaType.SortFriendWindow);
     scFriendLoadingAll = FriendModelLocator.Instance.ScFriendLoadingAll;
     friendInfos = new List<FriendInfo>(scFriendLoadingAll.FriendList);
     myself = scFriendLoadingAll.Myself;
     friendInfos.Add(scFriendLoadingAll.Myself);
     SortLabel.text = LanguageManager.Instance.GetTextValue(FriendUtils.SortNameKeys[(int)orderType]);
     Refresh(friendInfos);
     SortLis.onClick = OnSort;
 }
Exemplo n.º 39
0
 public static int GetProp(FriendInfo info, int key)
 {
     var result = 0;
     var prop = info.HeroProp;
     var count = prop.Count;
     for (var i = 0; i < count; i++)
     {
         result += prop[i].Prop[key];
     }
     return result;
 }
Exemplo n.º 40
0
 protected IList<FriendInfo> _generateFriendInfo(IList<Model.SB_User> models)
 {
     IList<FriendInfo> tiList = new List<FriendInfo>();
     foreach (var i in models)
     {
         FriendInfo tiThis = new FriendInfo();
         tiThis.Urlhead = i.User_HeadPhoto;
         tiThis.Friendid = i.User_ID;
         tiThis.Friendname = i.User_NickName;
         tiList.Add(tiThis);
     }
     return tiList;
 }
Exemplo n.º 41
0
 public void Init(FriendInfo info, int rank)
 {
     Init(info);
     if (rank < 3)
     {
         loserLabel.text = "";
         winerSprite.enabled = true;
         winerSprite.spriteName = ThreeWinnerSpriteNames[rank];
     }
     else
     {
         winerSprite.enabled = false;
         //The rank is base on zero, where the display number is based on one.
         loserLabel.text = "" + (rank + 1);
     }
 }
Exemplo n.º 42
0
 public override void Init(FriendInfo info)
 {
     base.Init(info);
     highestHit.text = info.MaxDamage.ToString();
     var raidTemp = MissionModelLocator.Instance.RaidTemplates;
     if (raidTemp.RaidStageTmpls.ContainsKey(info.RaidStageId))
     {
         var raidStage = raidTemp.RaidStageTmpls[info.RaidStageId];
         var raid = raidTemp.RaidTmpls[raidStage.RaidId];
         curPass.text = raid.RaidName + Separator + raidStage.StageName;
     }
     else
     {
         curPass.text = LanguageManager.Instance.GetTextValue(DefaultPassKey);
     }
 }
Exemplo n.º 43
0
    // Use this for first initialization
    void Awake()
    {
        // init friend list
        friendList = new List<FriendInfo>();
        for( int i=0; i<1000; i++ )
        {
            FriendInfo friendInfo = new FriendInfo( i, i.ToString(), "dummy_name_" + i.ToString() );
            friendList.Add( friendInfo );
        }

        friendList.Sort( SortByRank );

        // draggable panel init
        dragPanel = GetComponentInChildren<UIDraggablePanelEx>() as UIDraggablePanelEx;
        grid = GetComponentInChildren<UIGridEx>() as UIGridEx;

        FillGrid ();
    }
Exemplo n.º 44
0
    public void SetData(FriendInfo frienddata, bool isfriend)
    {
        IsFriendItem = true;
        IsFriend = isfriend;
        
        FriendData = frienddata;
        Attrack = 0;
        Hp = 0;
        Recover = 0;
        Mp = 0;
        TheLevel = FriendData.FriendLvl;
        for (int i = 0; i < FriendData.HeroProp.Count; i++)
        {
            if (FriendData.HeroProp[i].Prop.ContainsKey(RoleProperties.ROLE_ATK))
            {
                Attrack += FriendData.HeroProp[i].Prop[RoleProperties.ROLE_ATK];
                if (i == 0)
                {
                    LeaderAtk = FriendData.HeroProp[i].Prop[RoleProperties.ROLE_ATK];
                }
            }
            if (FriendData.HeroProp[i].Prop.ContainsKey(RoleProperties.ROLE_HP))
            {
                Hp += FriendData.HeroProp[i].Prop[RoleProperties.ROLE_HP];
                if (i == 0)
                {
                    LeaderHp = FriendData.HeroProp[i].Prop[RoleProperties.ROLE_HP];
                }
            }
            if (FriendData.HeroProp[i].Prop.ContainsKey(RoleProperties.ROLE_MP))
            {
                Mp += FriendData.HeroProp[i].Prop[RoleProperties.ROLE_MP];
            }
            if (FriendData.HeroProp[i].Prop.ContainsKey(RoleProperties.ROLE_RECOVER))
            {
                Recover += FriendData.HeroProp[i].Prop[RoleProperties.ROLE_RECOVER];
            }
        }

        ShowData();
    }
Exemplo n.º 45
0
 public void Refresh(FriendInfo info)
 {
     friendItem.Init(info);
 }
Exemplo n.º 46
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            if (CMSContext.CurrentUser.IsAuthenticated())
            {
                // Get requested action
                action = (FriendsActionEnum)Enum.Parse(typeof(FriendsActionEnum), QueryHelper.GetString("action", "request"), true);
                friendship = CommunityContext.CurrentFriendship;
                friend = CommunityContext.CurrentFriend;

                // Prepare My Friends link
                lnkMyFriends.Text = MyFriendsCaption;
                if (MyFriendsPath != string.Empty)
                {
                    lnkMyFriends.NavigateUrl = URLHelper.GetAbsoluteUrl(TreePathUtils.GetUrl(MyFriendsPath));
                }
                else
                {
                    lnkMyFriends.Visible = false;
                }

                // Validate requested action
                if (!ValidateAction())
                {
                    return;
                }

                btnApprove.Click += btnApprove_Click;
                btnReject.Click += btnReject_Click;

                if (friendship != null)
                {
                    // If friendship is rejected -> display error
                    switch (friendship.FriendStatus)
                    {
                        case FriendshipStatusEnum.Rejected:
                            plcMessage.Visible = true;
                            plcConfirm.Visible = false;
                            lblInfo.Text = AlreadyRejectedCaption;
                            lblInfo.ForeColor = Color.Red;
                            break;

                        case FriendshipStatusEnum.Approved:
                            plcMessage.Visible = true;
                            plcConfirm.Visible = false;
                            lblInfo.Text = AlreadyApprovedCaption;
                            lblInfo.ForeColor = Color.Red;
                            break;
                        default:
                            plcMessage.Visible = false;
                            plcConfirm.Visible = true;
                            btnApprove.Text = GetString("general.approve");
                            btnReject.Text = GetString("general.reject");

                            string profilePath = GroupMemberInfoProvider.GetMemberProfilePath(friend.UserName, CMSContext.CurrentSiteName);
                            string profileUrl = ResolveUrl(TreePathUtils.GetUrl(profilePath));
                            string link = "<a href=\"" + profileUrl + "\" >" + HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(friend.UserName, friend.FullName, true)) + "</a>";
                            lblConfirm.Text = string.Format(GetString("friends.approvaltext"), link);
                            break;
                    }
                }
                else
                {
                    Visible = false;
                }
            }
            else
            {
                plcMessage.Visible = true;
                plcConfirm.Visible = false;
                lblInfo.ForeColor = Color.Red;
                lblInfo.Text = GetString("friends.notloggedin");
            }
        }
    }
Exemplo n.º 47
0
 public static bool IsFriendBind(FriendInfo info)
 {
     return ((info.Status & FriendConstant.BindFlag) != 0);
 }
Exemplo n.º 48
0
 /// <summary>
 /// The comparation of friend info by attack.
 /// </summary>
 /// <param name="p1">The left friend info.</param>
 /// <param name="p2">The right friend info.</param>
 /// <returns>The result of the comparation</returns>
 public static int CompareFriendByAtk(FriendInfo p1, FriendInfo p2)
 {
     return GetProp(p2, RoleProperties.ROLE_ATK).CompareTo(GetProp(p1, RoleProperties.ROLE_ATK));
 }   
Exemplo n.º 49
0
 /// <summary>
 /// The comparation of friend info by level.
 /// </summary>
 /// <param name="p1">The left friend info.</param>
 /// <param name="p2">The right friend info.</param>
 /// <returns>The result of the comparation</returns>
 public static int CompareFriendByLevel(FriendInfo p1, FriendInfo p2)
 {
     return p2.FriendLvl.CompareTo(p1.FriendLvl);
 }
Exemplo n.º 50
0
 /// <summary>
 /// The comparation of friend info by max hit.
 /// </summary>
 /// <param name="p1">The left friend info.</param>
 /// <param name="p2">The right friend info.</param>
 /// <returns>The result of the comparation</returns>
 public static int CompareFriendByMaxHit(FriendInfo p1, FriendInfo p2)
 {
     return p2.MaxDamage.CompareTo(p1.MaxDamage);
 }
Exemplo n.º 51
0
        public override void FromOSD(OSDMap map)
        {
            AgentInfo = new IAgentInfo();
            AgentInfo.FromOSD((OSDMap) (map["AgentInfo"]));
            UserAccount = new UserAccount();
            UserAccount.FromOSD((OSDMap)(map["UserAccount"]));
            if (!map.ContainsKey("ActiveGroup"))
                ActiveGroup = null;
            else
            {
                ActiveGroup = new GroupMembershipData();
                ActiveGroup.FromOSD((OSDMap)(map["ActiveGroup"]));
            }
            GroupMemberships = ((OSDArray) map["GroupMemberships"]).ConvertAll<GroupMembershipData>((o) =>
                                                                                                        {
                                                                                                            GroupMembershipData
                                                                                                                group =
                                                                                                                    new GroupMembershipData
                                                                                                                        ();
                                                                                                            group
                                                                                                                .FromOSD
                                                                                                                ((OSDMap
                                                                                                                 ) o);
                                                                                                            return group;
                                                                                                        });
            OfflineMessages = ((OSDArray) map["OfflineMessages"]).ConvertAll<GridInstantMessage>((o) =>
                                                                                                     {
                                                                                                         GridInstantMessage
                                                                                                             group =
                                                                                                                 new GridInstantMessage
                                                                                                                     ();
                                                                                                         group.FromOSD(
                                                                                                             (OSDMap) o);
                                                                                                         return group;
                                                                                                     });
            MuteList = ((OSDArray) map["MuteList"]).ConvertAll<MuteList>((o) =>
                                                                             {
                                                                                 MuteList group = new MuteList();
                                                                                 group.FromOSD((OSDMap) o);
                                                                                 return group;
                                                                             });

            if (map.ContainsKey("Appearance"))
            {
                Appearance = new AvatarAppearance();
                Appearance.FromOSD((OSDMap)map["Appearance"]);
            }
            if (map.ContainsKey("FriendOnlineStatuses"))
                FriendOnlineStatuses = ((OSDArray)map["FriendOnlineStatuses"]).ConvertAll<UUID>((o) => { return o; });
            if (map.ContainsKey("Friends"))
                Friends = ((OSDArray)map["Friends"]).ConvertAll<FriendInfo>((o) =>
                {
                    FriendInfo f = new FriendInfo();
                    f.FromOSD((OSDMap)o);
                    return f;
                });
        }
Exemplo n.º 52
0
 private void RefreshLeaders(FriendInfo info)
 {
     var heroTemps = HeroModelLocator.Instance.HeroTemplates.HeroTmpls;
     for(int i = 0; i < info.HeroProp.Count; i++)
     {
         var heroTempId = info.HeroProp[i].HeroTemplateId;
         HeroConstant.SetHeadByTemplate(leaderIcons[i], heroTempId);
         leaderJobs[i].spriteName = HeroConstant.HeroJobPrefix + heroTemps[heroTempId].Job;
         leaderAtks[i].text = info.HeroProp[i].Prop[RoleProperties.ROLE_ATK].ToString();
     }
 }
    public void OnOperationResponse(OperationResponse operationResponse)
    {
        if (PhotonNetwork.networkingPeer.State == global::PeerState.Disconnecting)
        {
            if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
            {
                Debug.Log("OperationResponse ignored while disconnecting. Code: " + operationResponse.OperationCode);
            }
            return;
        }

        // extra logging for error debugging (helping developers with a bit of automated analysis)
        if (operationResponse.ReturnCode == 0)
        {
            if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
                Debug.Log(operationResponse.ToString());
        }
        else
        {
            if (operationResponse.ReturnCode == ErrorCode.OperationNotAllowedInCurrentState)
            {
                Debug.LogError("Operation " + operationResponse.OperationCode + " could not be executed (yet). Wait for state JoinedLobby or ConnectedToMaster and their callbacks before calling operations. WebRPCs need a server-side configuration. Enum OperationCode helps identify the operation.");
            }
            else if (operationResponse.ReturnCode == ErrorCode.WebHookCallFailed)
            {
                Debug.LogError("Operation " + operationResponse.OperationCode + " failed in a server-side plugin. Check the configuration in the Dashboard. Message from server-plugin: " + operationResponse.DebugMessage);
            }
            else if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
            {
                Debug.LogError("Operation failed: " + operationResponse.ToStringFull() + " Server: " + this.server);
            }
        }

        // use the "secret" or "token" whenever we get it. doesn't really matter if it's in AuthResponse.
        if (operationResponse.Parameters.ContainsKey(ParameterCode.Secret))
        {
            if (this.CustomAuthenticationValues == null)
            {
                this.CustomAuthenticationValues = new AuthenticationValues();
                // this.DebugReturn(DebugLevel.ERROR, "Server returned secret. Created CustomAuthenticationValues.");
            }

            this.CustomAuthenticationValues.Secret = operationResponse[ParameterCode.Secret] as string;
        }

        switch (operationResponse.OperationCode)
        {
            case OperationCode.Authenticate:
                {
                    // PeerState oldState = this.State;

                    if (operationResponse.ReturnCode != 0)
                    {
                        if (operationResponse.ReturnCode == ErrorCode.InvalidOperationCode)
                        {
                            Debug.LogError(string.Format("If you host Photon yourself, make sure to start the 'Instance LoadBalancing' "+ this.ServerAddress));
                        }
                        else if (operationResponse.ReturnCode == ErrorCode.InvalidAuthentication)
                        {
                            Debug.LogError(string.Format("The appId this client sent is unknown on the server (Cloud). Check settings. If using the Cloud, check account."));
                            SendMonoMessage(PhotonNetworkingMessage.OnFailedToConnectToPhoton, DisconnectCause.InvalidAuthentication);
                        }
                        else if (operationResponse.ReturnCode == ErrorCode.CustomAuthenticationFailed)
                        {
                            Debug.LogError(string.Format("Custom Authentication failed (either due to user-input or configuration or AuthParameter string format). Calling: OnCustomAuthenticationFailed()"));
                            SendMonoMessage(PhotonNetworkingMessage.OnCustomAuthenticationFailed, operationResponse.DebugMessage);
                        }
                        else
                        {
                            Debug.LogError(string.Format("Authentication failed: '{0}' Code: {1}", operationResponse.DebugMessage, operationResponse.ReturnCode));
                        }

                        this.State = global::PeerState.Disconnecting;
                        this.Disconnect();

                        if (operationResponse.ReturnCode == ErrorCode.MaxCcuReached)
                        {
                            if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
                                Debug.LogWarning(string.Format("Currently, the limit of users is reached for this title. Try again later. Disconnecting"));
                            SendMonoMessage(PhotonNetworkingMessage.OnPhotonMaxCccuReached);
                            SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, DisconnectCause.MaxCcuReached);
                        }
                        else if (operationResponse.ReturnCode == ErrorCode.InvalidRegion)
                        {
                            if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
                                Debug.LogError(string.Format("The used master server address is not available with the subscription currently used. Got to Photon Cloud Dashboard or change URL. Disconnecting."));
                            SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, DisconnectCause.InvalidRegion);
                        }
                        else if (operationResponse.ReturnCode == ErrorCode.AuthenticationTicketExpired)
                        {
                            if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
                                Debug.LogError(string.Format("The authentication ticket expired. You need to connect (and authenticate) again. Disconnecting."));
                            SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, DisconnectCause.AuthenticationTicketExpired);
                        }
                        break;
                    }
                    else
                    {
                        if (this.server == ServerConnection.NameServer)
                        {
                            // on the NameServer, authenticate returns the MasterServer address for a region and we hop off to there
                            this.MasterServerAddress = operationResponse[ParameterCode.Address] as string;
                            this.DisconnectToReconnect();
                        }
                        else if (this.server == ServerConnection.MasterServer)
                        {
                            if (PhotonNetwork.autoJoinLobby)
                            {
                                this.State = global::PeerState.Authenticated;
                                this.OpJoinLobby(this.lobby);
                            }
                            else
                            {
                                this.State = global::PeerState.ConnectedToMaster;
                                NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnConnectedToMaster);
                            }
                        }
                        else if (this.server == ServerConnection.GameServer)
                        {
                            this.State = global::PeerState.Joining;

                            if (this.mLastJoinType == JoinType.JoinGame || this.mLastJoinType == JoinType.JoinRandomGame || this.mLastJoinType == JoinType.JoinOrCreateOnDemand)
                            {
                                // if we just "join" the game, do so. if we wanted to "create the room on demand", we have to send this to the game server as well.
                                this.OpJoinRoom(this.mRoomToGetInto.name, this.mRoomOptionsForCreate, this.mRoomToEnterLobby, this.mLastJoinType == JoinType.JoinOrCreateOnDemand);
                            }
                            else if (this.mLastJoinType == JoinType.CreateGame)
                            {
                                // on the game server, we have to apply the room properties that were chosen for creation of the room, so we use this.mRoomToGetInto
                                this.OpCreateGame(this.mRoomToGetInto.name, this.mRoomOptionsForCreate, this.mRoomToEnterLobby);
                            }

                            break;
                        }
                    }
                    break;
                }

            case OperationCode.GetRegions:
                // Debug.Log("GetRegions returned: " + operationResponse.ToStringFull());

                if (operationResponse.ReturnCode == ErrorCode.InvalidAuthentication)
                {
                    Debug.LogError(string.Format("The appId this client sent is unknown on the server (Cloud). Check settings. If using the Cloud, check account."));
                    SendMonoMessage(PhotonNetworkingMessage.OnFailedToConnectToPhoton, DisconnectCause.InvalidAuthentication);

                    this.State = global::PeerState.Disconnecting;
                    this.Disconnect();
                    return;
                }

                string[] regions = operationResponse[ParameterCode.Region] as string[];
                string[] servers = operationResponse[ParameterCode.Address] as string[];

                if (regions == null || servers == null || regions.Length != servers.Length)
                {
                    Debug.LogError("The region arrays from Name Server are not ok. Must be non-null and same length.");
                    break;
                }

                this.AvailableRegions = new List<Region>(regions.Length);
                for (int i = 0; i < regions.Length; i++)
                {
                    string regionCodeString = regions[i];
                    if (string.IsNullOrEmpty(regionCodeString))
                    {
                        continue;
                    }
                    regionCodeString = regionCodeString.ToLower();

                    CloudRegionCode code = Region.Parse(regionCodeString);
                    this.AvailableRegions.Add(new Region() { Code = code, HostAndPort = servers[i] });
                }

                // PUN assumes you fetch the name-server's list of regions to ping them
                if (PhotonNetwork.PhotonServerSettings.HostType == ServerSettings.HostingOption.BestRegion)
                {
                    PhotonHandler.PingAvailableRegionsAndConnectToBest();
                }
                break;

            case OperationCode.CreateGame:
                {
                    if (this.server == ServerConnection.GameServer)
                    {
                        this.GameEnteredOnGameServer(operationResponse);
                    }
                    else
                    {
                        if (operationResponse.ReturnCode != 0)
                        {
                            if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
                                Debug.LogWarning(string.Format("CreateRoom failed, client stays on masterserver: {0}.", operationResponse.ToStringFull()));

                            SendMonoMessage(PhotonNetworkingMessage.OnPhotonCreateRoomFailed);
                            break;
                        }

                        string gameID = (string) operationResponse[ParameterCode.RoomName];
                        if (!string.IsNullOrEmpty(gameID))
                        {
                            // is only sent by the server's response, if it has not been
                            // sent with the client's request before!
                            this.mRoomToGetInto.name = gameID;
                        }

                        this.mGameserver = (string)operationResponse[ParameterCode.Address];
                        this.DisconnectToReconnect();
                    }

                    break;
                }

            case OperationCode.JoinGame:
                {
                    if (this.server != ServerConnection.GameServer)
                    {
                        if (operationResponse.ReturnCode != 0)
                        {
                            if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
                                Debug.Log(string.Format("JoinRoom failed (room maybe closed by now). Client stays on masterserver: {0}. State: {1}", operationResponse.ToStringFull(), this.State));

                            SendMonoMessage(PhotonNetworkingMessage.OnPhotonJoinRoomFailed);
                            break;
                        }

                        this.mGameserver = (string)operationResponse[ParameterCode.Address];
                        this.DisconnectToReconnect();
                    }
                    else
                    {
                        this.GameEnteredOnGameServer(operationResponse);
                    }

                    break;
                }

            case OperationCode.JoinRandomGame:
                {
                    // happens only on master. on gameserver, this is a regular join (we don't need to find a random game again)
                    // the operation OpJoinRandom either fails (with returncode 8) or returns game-to-join information
                    if (operationResponse.ReturnCode != 0)
                    {
                        if (operationResponse.ReturnCode == ErrorCode.NoRandomMatchFound)
                        {
                            if (PhotonNetwork.logLevel >= PhotonLogLevel.Full)
                                Debug.Log("JoinRandom failed: No open game. Calling: OnPhotonRandomJoinFailed() and staying on master server.");
                        }
                        else if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
                        {
                            Debug.LogWarning(string.Format("JoinRandom failed: {0}.", operationResponse.ToStringFull()));
                        }

                        SendMonoMessage(PhotonNetworkingMessage.OnPhotonRandomJoinFailed, operationResponse.ReturnCode, operationResponse.DebugMessage);
                        break;
                    }

                    string roomName = (string)operationResponse[ParameterCode.RoomName];
                    this.mRoomToGetInto.name = roomName;
                    this.mGameserver = (string)operationResponse[ParameterCode.Address];
                    this.DisconnectToReconnect();
                    break;
                }

            case OperationCode.JoinLobby:
                this.State = global::PeerState.JoinedLobby;
                this.insideLobby = true;
                SendMonoMessage(PhotonNetworkingMessage.OnJoinedLobby);

                // this.mListener.joinLobbyReturn();
                break;
            case OperationCode.LeaveLobby:
                this.State = global::PeerState.Authenticated;
                this.LeftLobbyCleanup();    // will set insideLobby = false
                break;

            case OperationCode.Leave:
                this.DisconnectToReconnect();
                break;

            case OperationCode.SetProperties:
                // this.mListener.setPropertiesReturn(returnCode, debugMsg);
                break;

            case OperationCode.GetProperties:
                {
                    Hashtable actorProperties = (Hashtable)operationResponse[ParameterCode.PlayerProperties];
                    Hashtable gameProperties = (Hashtable)operationResponse[ParameterCode.GameProperties];
                    this.ReadoutProperties(gameProperties, actorProperties, 0);

                    // RemoveByteTypedPropertyKeys(actorProperties, false);
                    // RemoveByteTypedPropertyKeys(gameProperties, false);
                    // this.mListener.getPropertiesReturn(gameProperties, actorProperties, returnCode, debugMsg);
                    break;
                }

            case OperationCode.RaiseEvent:
                // this usually doesn't give us a result. only if the caching is affected the server will send one.
                break;

            case OperationCode.FindFriends:
                bool[] onlineList = operationResponse[ParameterCode.FindFriendsResponseOnlineList] as bool[];
                string[] roomList = operationResponse[ParameterCode.FindFriendsResponseRoomIdList] as string[];

                if (onlineList != null && roomList != null && this.friendListRequested != null && onlineList.Length == this.friendListRequested.Length)
                {
                    List<FriendInfo> friendList = new List<FriendInfo>(this.friendListRequested.Length);
                    for (int index = 0; index < this.friendListRequested.Length; index++)
                    {
                        FriendInfo friend = new FriendInfo();
                        friend.Name = this.friendListRequested[index];
                        friend.Room = roomList[index];
                        friend.IsOnline = onlineList[index];
                        friendList.Insert(index, friend);
                    }
                    PhotonNetwork.Friends = friendList;
                }
                else
                {
                    // any of the lists is null and shouldn't. print a error
                    Debug.LogError("FindFriends failed to apply the result, as a required value wasn't provided or the friend list length differed from result.");
                }

                this.friendListRequested = null;
                this.isFetchingFriends = false;
                this.friendListTimestamp = Environment.TickCount;
                if (this.friendListTimestamp == 0)
                {
                    this.friendListTimestamp = 1;   // makes sure the timestamp is not accidentally 0
                }

                SendMonoMessage(PhotonNetworkingMessage.OnUpdatedFriendList);
                break;

            case OperationCode.WebRpc:
                SendMonoMessage(PhotonNetworkingMessage.OnWebRpcResponse, operationResponse);
                break;

            default:
                Debug.LogWarning(string.Format("OperationResponse unhandled: {0}", operationResponse.ToString()));
                break;
        }

        this.externalListener.OnOperationResponse(operationResponse);
    }
    /// <summary>
    /// Gets and bulk updates friends. Called when the "Get and bulk update friends" button is pressed.
    /// Expects the RequestFriendship method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateFriends()
    {
        // Get the user
        UserInfo friend = UserInfoProvider.GetUserInfo("MyNewFriend");

        if (friend != null)
        {
            // Prepare the parameters
            string where = "FriendRequestedUserID = " + friend.UserID;

            // Get the data
            DataSet friends = FriendInfoProvider.GetFriends(where, null);
            if (!DataHelper.DataSourceIsEmpty(friends))
            {
                // Loop through the individual items
                foreach (DataRow friendDr in friends.Tables[0].Rows)
                {
                    // Create object from DataRow
                    FriendInfo modifyFriend = new FriendInfo(friendDr);

                    // Update the properties
                    modifyFriend.FriendStatus = FriendshipStatusEnum.Approved;
                    modifyFriend.FriendRejectedBy = 0;
                    modifyFriend.FriendApprovedBy = MembershipContext.AuthenticatedUser.UserID;
                    modifyFriend.FriendApprovedWhen = DateTime.Now;

                    // Save the changes
                    FriendInfoProvider.SetFriendInfo(modifyFriend);
                }

                return true;
            }
        }
        return false;
    }
Exemplo n.º 55
0
 private void Friends_OnFriendOnline(FriendInfo friend)
 {
     RefreshFriends();
 }
Exemplo n.º 56
0
 public static int SortByRank(FriendInfo a, FriendInfo b)
 {
     return (a.nRank < b.nRank ? 1 : -1);
 }
Exemplo n.º 57
0
 // sort for FriendInfo
 public static int SortByName(FriendInfo a, FriendInfo b)
 {
     return string.Compare(a.strName, b.strName);
 }
Exemplo n.º 58
0
 public void Init(FriendInfo info)
 {
     FriendInfo = info;
 }
    /// <summary>
    /// Creates friend. Called when the "Create friend" button is pressed.
    /// </summary>
    private bool RequestFriendship()
    {
        // First create a new user which the friendship request will be sent to
        UserInfo newFriend = new UserInfo();
        newFriend.UserName = "******";
        newFriend.FullName = "My new friend";
        newFriend.UserGUID = Guid.NewGuid();

        UserInfoProvider.SetUserInfo(newFriend);

        // Create new friend object
        FriendInfo newFriendship = new FriendInfo();

        // Set the properties
        newFriendship.FriendUserID = MembershipContext.AuthenticatedUser.UserID;
        newFriendship.FriendRequestedUserID = newFriend.UserID;
        newFriendship.FriendRequestedWhen = DateTime.Now;
        newFriendship.FriendComment = "Sample friend request comment.";
        newFriendship.FriendStatus = FriendshipStatusEnum.Waiting;
        newFriendship.FriendGUID = Guid.NewGuid();

        // Save the friend
        FriendInfoProvider.SetFriendInfo(newFriendship);

        return true;
    }
    /// <summary>
    /// Deletes all friends of "My new user". Called when the "Delete friends" button is pressed.
    /// Expects the CreateFriend method to be run first.
    /// </summary>
    private bool DeleteFriends()
    {
        // Get the user
        UserInfo friend = UserInfoProvider.GetUserInfo("MyNewFriend");

        if (friend != null)
        {
            // Prepare the parameters
            string where = "FriendRequestedUserID = " + friend.UserID;

            // Get all user's friendships
            DataSet friends = FriendInfoProvider.GetFriends(where, null);
            if (!DataHelper.DataSourceIsEmpty(friends))
            {
                // Delete all the friendships
                foreach (DataRow friendDr in friends.Tables[0].Rows)
                {
                    FriendInfo deleteFriend = new FriendInfo(friendDr);

                    FriendInfoProvider.DeleteFriendInfo(deleteFriend);
                }
            }
            else
            {
                // Change the info message
                apiDeleteFriends.InfoMessage = "The user 'My new friend' doesn't have any friends. The user has been deleted.";
            }

            // Finally delete the user "My new friend"
            UserInfoProvider.DeleteUser(friend);

            return true;
        }

        return false;
    }