Exemplo n.º 1
0
    public bool SetNotifyLog(NotifyLog log)
    {
        bool bFlag = false;

        if (netdata.m_NotifyLog.game_id != 0 && netdata.m_NotifyLog.game_id != log.game_id)
        {
            bFlag = true;
        }

        netdata.m_NotifyLog = log;
        return(bFlag);
    }
Exemplo n.º 2
0
    void P_USER_NOTIFY(JSONObject jsonObj)
    {
        JSONObject obj = jsonObj["info"];

        if (obj == null || obj["game_id"] == null)
        {
            return;
        }

        ulong game_id  = (ulong)obj["game_id"].n;
        ulong attacker = (ulong)obj["attacker"].n;
        ulong coin     = (ulong)obj["coin"].n;

        NotifyLog log = new NotifyLog();

        log.game_id     = game_id;
        log.attacker_id = attacker;
        log.coin        = coin;

        if (DataManager.instance.SetNotifyLog(log))
        {
            UIManager.instance.SetNotify();
        }
    }
Exemplo n.º 3
0
    public void SetNotify()
    {
        NotifyLog log = DataManager.instance.GetNotifyLog();

        if (log == null)
        {
            return;
        }

        ulong Coin = DataManager.instance.GetCoin();

        DataManager.instance.SetCoin(Coin - log.coin);

        SirenDesc.text = DataManager.instance.GetRankName(log.attacker_id) + " 에게 내 금고를 털렸습니다.\n보유금액이 감소 되었습니다.";

        TweenPosition[] tweens = Siren.GetComponents <TweenPosition>();
        foreach (var tween in tweens)
        {
            tween.ResetToBeginning();
            tween.PlayForward();
        }

        Siren.SetActive(true);
    }
Exemplo n.º 4
0
        public static AndroidFCMPushNotificationStatus SendNotification(string deviceId, string msg, int userId, string title)
        {
            AndroidFCMPushNotificationStatus result = new AndroidFCMPushNotificationStatus();

            try
            {
                result.Successful = false;
                result.Error      = null;
                var serverApiKey = Convert.ToString(ConfigurationSettings.AppSettings["FcmServerApiKeyFO"]);

                var senderId = Convert.ToString(ConfigurationSettings.AppSettings["FcmsenderIdFO"]);
                //deviceId = "fiw592fD138:APA91bHqE4yzlcp3OVX3hHYBz3NE3oJBpz3b6JlFOXu2-wZPTajYLNyRD0BHPsvCG09pZv54zbNMVLW8rdJLArlg0aEHRDmB9z59ATQORy3FpVsnDTSgDh6XnMEjS7iDx_owcbPpSujs";
                // var deviceId = "ae03efc8462cc55a";

                WebRequest tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send");
                tRequest.Method = "post";
                //  tRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
                tRequest.Headers.Add(string.Format("Authorization: key={0}", serverApiKey));
                tRequest.Headers.Add(string.Format("Sender: id={0}", senderId));

                // string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.message=" + value + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + deviceId + "";

                //Byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                tRequest.ContentType = "application/json";
                //     tRequest.UseDefaultCredentials = true;
                //    tRequest.PreAuthenticate = true;
                //   tRequest.Credentials = CredentialCache.DefaultCredentials;

                var data = new
                {
                    to           = deviceId,
                    notification = new
                    {
                        body  = msg,
                        title = title
                    }
                };
                var    serializer = new JavaScriptSerializer();
                var    json       = serializer.Serialize(data);
                Byte[] byteArray  = Encoding.UTF8.GetBytes(json);


                tRequest.ContentLength = byteArray.Length;

                using (Stream dataStream = tRequest.GetRequestStream())
                {
                    dataStream.Write(byteArray, 0, byteArray.Length);

                    using (WebResponse tResponse = tRequest.GetResponse())
                    {
                        using (Stream dataStreamResponse = tResponse.GetResponseStream())
                        {
                            using (StreamReader tReader = new StreamReader(dataStreamResponse))
                            {
                                String      sResponseFromServer = tReader.ReadToEnd();
                                FCMResponse response            = Newtonsoft.Json.JsonConvert.DeserializeObject <FCMResponse>(sResponseFromServer);
                                if (response.success == 1)
                                {
                                    var newTbl_NotifyLog = new NotifyLog();
                                    newTbl_NotifyLog.FcmId       = deviceId;
                                    newTbl_NotifyLog.AppKeyId    = serverApiKey;
                                    newTbl_NotifyLog.Msg         = msg;
                                    newTbl_NotifyLog.Status      = "Success";
                                    newTbl_NotifyLog.MsgId       = response.results[0].message_id;
                                    newTbl_NotifyLog.CreatedDate = DateTime.Now.ToString();
                                    newTbl_NotifyLog.CreatedBy   = userId;
                                    new ReasonStatusDal().SaveNotifyLog(newTbl_NotifyLog);
                                }
                                else if (response.failure == 1)
                                {
                                    var newTbl_NotifyLog = new NotifyLog();
                                    newTbl_NotifyLog.FcmId       = deviceId;
                                    newTbl_NotifyLog.AppKeyId    = serverApiKey;
                                    newTbl_NotifyLog.Msg         = msg;
                                    newTbl_NotifyLog.ErrorMsg    = response.results[0].error;
                                    newTbl_NotifyLog.Status      = "Failure";
                                    newTbl_NotifyLog.CreatedDate = DateTime.Now.ToString();
                                    newTbl_NotifyLog.CreatedBy   = userId;
                                    new ReasonStatusDal().SaveNotifyLog(newTbl_NotifyLog);
                                }

                                result.Response = sResponseFromServer;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var newErrorLog = new ErrorLog();
                newErrorLog.ControllerName = "Notification";
                newErrorLog.ActionName     = "SendNotification";
                newErrorLog.Msg            = ex.Message;
                newErrorLog.Type           = title + " Console";
                LogBal.ErrorLog("CommonBal", "SendNotification", ex.Message, 0);
                //   new DataLayer().SaveErrorLog(newErrorLog);
                //result.Successful = false;
                //result.Response = null;
                //result.Error = ex;
            }

            return(result);
        }